Ajax数据传递格式

$.ajax({
url: '/login',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify({"name": username, "pwd": password}),

success: function (data, status) {
if (status == 'success') {
if (data === '0') {
alert("用户不存在,请先注册");
} else {
alert("登陆成功");
// location.href='/'
this.props.onName(username);

browserHistory.push('/');
}
}
}.bind(this),
error: function (data, status) {
if (status == "error") {
// location.href='login'
}
}
});
posted @ 2016-08-15 00:32  蝴蝶女郎  阅读(80)  评论(0)    收藏  举报