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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -