codehaven - php snippets - coding help
Generic filters
Exact matches only

Pass Ampersand using Ajax – Jquery

13th February 2020

Jquery - Variables

jquery icon

Pass Ampersand using Ajax,,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

or this example

Was this code snippet helpful?