Click here to Skip to main content
15,888,177 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Heloo Friends,

I am using visual studio 2005.I have written following code for the'onblur' event of textbox using javascript.

whenever i enter text with Apostrophe then it writtens null value.I dont know where is the issue.I also debugged it and found that ajax throwing error.Please help me as its urgent.

JavaScript
function txtBlurNarr(obj) {
           if (document.getElementById('<%=txtnarr.ClientID%>').value == "") {
           }
           else {
               var narr = document.getElementById('<%=txtnarr.ClientID%>').value;
               var passpar = narr;
               debugger;
               $(document).ready(function() {
                   //     alert("Inside Jquery");
                   $.ajax({
                       type: "POST",
                       url: "jstest.aspx/CheckoutNarr",
                       data: "{'parameter':'" + passpar + "'}",
                       contentType: "application/json; charset=utf-8",
                       dataType: "json",
                       async: true,
                       cache: false,
                       success: function(msg) {
                           var retvalue = msg.d;
                       }
                   })
                   return false;
               });
           }
       }


thanks in advance.
Posted
Updated 26-Sep-13 22:21pm
v2

1 solution

Use - JSON.stringify()[^].
JavaScript
data: JSON.stringify({'parameter':'" + passpar + "'}),
 
Share this answer
 
Comments
Aysha Patel 27-Sep-13 6:59am    
Gives me error that JSON is not found....when i use ur data: JSON.stringify({'parameter':'" + passpar + "'}),
Please include the below file in your code.

json.js[^]
Aysha Patel 27-Sep-13 7:13am    
I didnt get u...How and where i include it??
Aysha Patel 27-Sep-13 7:14am    
Should i copy ths file in my project?
Yes. Just save this file and add in your project. Also link this file in the page.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900