jquery - Ajax sending datastring error when a variable contains amparsand -


i making program submit form ajax combining values in variable datastring , sending ajax method..

suppose

var varname="ram"; var varage=18;  , var datastring='name='+varname+'&age='+varage; 

this works but

var varname="ram & shyam"; var varage=18;  , var datastring='name='+varname+'&age='+varage; 

when variable contain & in value received php code $_post['name'] has value 'ram' not 'ram & shyam'

please tell solution problem

try replace

 var varname="ram & shyam";  var senddata = varname.replace("&","%26"); 

another useful links

how can send "&" (ampersand) character via ajax?

http://www.w3schools.com/tags/ref_urlencode.asp

https://developer.mozilla.org/en-us/docs/web/javascript/reference/global_objects/encodeuricomponent


Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -