亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

怎么給jquery跨域post請求添加頭部信息?

怎么給jquery跨域post請求添加頭部信息?

PHP
慕碼人8056858 2019-03-04 01:31:11
跨域,服務器已開放請求接口,用$post可以成功,但是無法添加header信息,用$ajax的話會把post信息換成OPTIONS發送請求,data跟header都無法發送出去,不知道有什么好的辦法可以解決~~ // $.post(Common.postUrl + '/wechat/register', // JSON.stringify({ // phone: tel, // publicId: getcookie().publicId, // header: header, // authCode: code, // focusTime: Date.parse(new Date()) // }), 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(new Date()) }), contentType: "application/x-www-form-urlencoded", headers:{ key:'Cookie' }, processData: false, beforeSend: function (xhr) { xhr.setRequestHeader("key", "Cookie"); }, success: function (data) { } });
查看完整描述

5 回答

?
鴻蒙傳說

TA貢獻1865條經驗 獲得超7個贊

還沒有找到原因,有沒有大佬能夠給點建議啊~~

查看完整回答
反對 回復 2019-03-18
?
慕的地6264312

TA貢獻1817條經驗 獲得超6個贊

你好!我想問下,你那個ajax跨域請求是如何把請求頭發過去的,在后臺怎么設置的。謝謝

查看完整回答
反對 回復 2019-03-18
?
慕田峪9158850

TA貢獻1794條經驗 獲得超8個贊

身邊發生的那

查看完整回答
反對 回復 2019-03-18
  • 5 回答
  • 0 關注
  • 829 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號