I am sending quite a few values with my AJAX call, like this:
var postData = "aid="+aid+"&lid="+lid+"&token="+token+"&count="+count+"&license="+license;
postData = postData + "&category="+category+"&event_name="+event_name+"&set_menu="+set_menu;
postData = postData + "&set_id="+set_id+"&location="+location+"&delay="+delay;
and then sending the call like this:
$.ajax({
type : 'GET',
url : 'ajax/createFolderID.asp',
dataType : 'html',
data : postData,
success : function() { do something },
complete : function() { do something },
error : function() { do something }
});
The problem is, one of the querystring values, "event_name", comes from user input. If the user enters an ampersand (&) symbol, the postData string breaks and won't send anything after that symbol.
Example case: &event_name=D&G Clothing Launch Party&set_menu=existing...
I understand what is going wrong, but not so sure what the best fix would be. Do I convert those characters to something else, or is there a way of escaping them? Also, are there any other characters that will cause harm to the script, like plus (+) or minus (-) signs, or apostrophes (')?