跨域,服務(wù)器已開(kāi)放請(qǐng)求接口,用$post可以成功,但是無(wú)法添加header信息,用$ajax的話會(huì)把post信息換成OPTIONS發(fā)送請(qǐng)求,data跟header都無(wú)法發(fā)送出去,不知道有什么好的辦法可以解決~~//$.post(Common.postUrl+'/wechat/register',//JSON.stringify({//phone:tel,//publicId:getcookie().publicId,//header:header,//authCode:code,//focusTime:Date.parse(newDate())//}),function(data){//data=JSON.parse(data);//if(data.status==200){//alertBottom('登錄成功');//setTimeout(function(){//window.href='index.html';//},2000)//}else{//alertBottom(returnMessage[data.status]);//}//});$.ajax({type:"POST",url:Common.postUrl+'/wechat/register',data:JSON.stringify({phone:tel,publicId:getcookie().publicId,header:header,authCode:code,focusTime:Date.parse(newDate())}),contentType:"application/x-www-form-urlencoded",headers:{key:'Cookie'},processData:false,beforeSend:function(xhr){xhr.setRequestHeader("key","Cookie");},success:function(data){}});
怎么給jquery跨域post請(qǐng)求添加頭部信息?
收到一只叮咚
2019-05-22 16:44:40