How do I pass a a large string containing characters like ‘%’ and ‘&’
to my php page through ajax post?
In other words how to javascript-encode them and php-decode them?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
the
encodeURIComponent()JavaScript function can be used to escape any of those characters in either the keys or the values.PHP will receive and decode it automatically into the
$_POSTarray.The format of the data should be Query String format, specifically:
For example:
If you use
encodeURIComponent()on each key and each value, then join them with=, and group them by&, you won’t have any further issues.