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

hibernate - How to load global settings frequently used in application in Java -

python 3.x - Mapping specific letters onto a list of words -

objective c - Ownership modifiers with manual reference counting -