If the post data contains “&” character it thinks it’s separating query string parameters. If it contains + it thinks it’s a space. I’m sure there’s some prebuilt function that takes care of these things already.
If the post data contains & character it thinks it’s separating query string parameters.
Share
Just pass your data as an object and jQuery will serialize it via
$.param()internally, for example:All the magic is basic JavaScript though,
$.param()just usesencodeURIComponent()underneath to do the serialization (including&encoding) when creating the string.If you’re sending an entire
<form>just use.serialize()which serializes the entire<form>(all successful form elements) to the string – like a normal non-AJAX submit would, for example: