php - Javascript & problems -


i have following code:

var artist = document.getelementbyid("txtboxartist").value; 

when value plain text, e.g. biffy clyro, artist = biffy clyro

when value contains &, e.g. mumford & sons, artist = mumford

i send artist value using ajax, , recover value on php page this:

var data = "nametitle=" + title + "&nameartist=" + artist; 

[...]

$nameartist=$_post['nameartist']; 

why happen , how avoid it? giving me lots of problems &symbol...

thank all!

i guess can encode valiables before sending them this:

 artist = encodeuricomponent(artist);  title = encodeuricomponent(title);  var data = "nametitle=" + title + "&nameartist=" + artist; 

hope helps.


Comments

Popular posts from this blog

apache - Remove .php and add trailing slash in url using htaccess not loading css -

javascript - jQuery show full size image on click -