Should encodeURIComponent be used to encode parameters of post ajax request?
Should encodeURIComponent be 开发者_Python百科used to encode parameters of post ajax request?
Thanks Yosef
Assuming your request is using the content type application/x-www-form-urlencoded
, then yes, it should — POST fields are also in name value pairs, just like GET requests. Special characters like &
, =
, [
, ]
, etc need to be encoded just the same.
Yes, you never know when an ampersand is plotting against you.
精彩评论