javascript - escape single quote from last name in jquery -


i have ajax call in jquery code doing lookup c# web method.

the call works of time, user needs enter last name , results last name.

the problem happens when user enter last name single quote included such o'leary.

this jquery line using:

   data: "{selectedagent: '" + $('#<%=txtagentnametext.clientid %>').val() + "',     companyid: '" + $('#<%=ddlcompany.clientid %>').val() + "'}", 

the problem happens txtagentnametext.clientid value.

it looks passing json string jquery ajax method. why not pass javascript object?

var data = {             selectedagent:$('#<%=txtagentnametext.clientid %>').val(),             companyid: $('#<%=ddlcompany.clientid %>').val()            };  $.ajax({...data:data...}) 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -