使用jquery +ajax 发起post 请求需要跨域。在为ajax 添加跨域后发现post 请求参数丢失.
var ajaxRequest= $.ajax({
url: subUrl+"/form/StuInformation" ,
type:"POST",
data:{
"username": $.trim($("#subUsername").val()),
"stuNickname": $.trim($("#subNickname").val()),
"stuMajor": $.trim($("#subMajor").val()),
"stuClass": $.trim($("#subClass").val()),
"stuNo": $.trim($("#subNO").val()),
"email": $.trim($("#subEmail").val()),
"verificationCode": $.trim($("#checking").val()),
"vaptcha_server": $.trim($("input[name='vaptcha_server']").val()),
"vaptcha_token": $.trim($("input[name='vaptcha_token']").val())
},
dataType: "json",
timeout: 3000,
xhrFields: {
withCredentials: true
},
crossDomain: true,
success:function (data){
if(data.statusCode==200){
//跳转到下载须知;
}else{
alert(data.message);
}
},
complete : function(XMLHttpRequest,status){ //请求完成后最终执行参数
if(status=='timeout'){//超时,status还有success,error等值的情况
ajaxRequest.abort();
alert("服务器超时")
}
}
有哪位大神知道原因吗?帮忙解答一下吧