jQuery ajax传入参数含有特殊字符的解决方法

WBOY
Release: 2016-06-01 09:54:13
Original
1293 people have browsed it

在做ajax登录时候遇到的一个问题,

当传入参数含有特殊字符,比如:“$'#@”等。参数传递会有问题,无法正确获取。

$.ajax({ url: '/user/login.ydd', type:'post', data:'name=abce&password=abcd&pwd', success: function(data){ } })
Copy after login

我要传入的是用户名为:abc,密码为abcd&pwd的用户登录。但传入后台获取参数,会被password=abcd当作一个参数传递,&这个特殊将pwd分开了作为另一个参数解析了。

解决方法,这时候就需要ajax另外一种传递参数的方式

$.ajax({ url: '/user/login.ydd', type:'post', data:{'name':'abce','password':'abcd&pwd'}, success: function(data){ } })
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!