When you are passing Jquery variables via Ajax, if the text contains an ampersand (&) it will cut the text at that specific point. it will only pass the text up to it.
Therefore “cat & dog” becomes “cat”. to prevent this from happening you need to add a simple bit of code that should be used in all ajax posts, if you think it will ever contain an ampersand. Which would be 95% of the time.
This will also escape ampersand in urls
1 2 3 |
myvar = encodeURIComponent(myvar); //pass ampersand |
or this example
1 2 3 4 |
var output = "dog&cat"; output = encodeURIComponent(output); |