解決ajax跨域請(qǐng)求數(shù)據(jù)cookie丟失問(wèn)題
來(lái)源:易賢網(wǎng) 閱讀:1155 次 日期:2015-04-29 15:16:35
溫馨提示:易賢網(wǎng)小編為您整理了“解決ajax跨域請(qǐng)求數(shù)據(jù)cookie丟失問(wèn)題”,方便廣大網(wǎng)友查閱!

前端:

以jquery為例:

需要加入

代碼如下:

xhrFields: {

withCredentials: true

},

crossDomain: true,

$.ajax({

type: postType,

url: url,

data: postData || '',

xhrFields: {

withCredentials: true

},

crossDomain: true,

success: function () {

successCallback.apply(scope || this, arguments);

},

failureCallback: function () {

failureCallback.apply(scope || this, arguments);

},

dataType: dataType

});

服務(wù)器端:

以php為例:

代碼如下:

header("Access-Control-Allow-Credentials: true");

header('Access-Control-Allow-Origin: );

根據(jù)自己的情況而定

以上所述就是本文關(guān)于解決ajax跨域請(qǐng)求數(shù)據(jù)時(shí)cookie丟失的處理方案,希望大家能夠喜歡。

更多信息請(qǐng)查看IT技術(shù)專(zhuān)欄

更多信息請(qǐng)查看網(wǎng)頁(yè)制作
易賢網(wǎng)手機(jī)網(wǎng)站地址:解決ajax跨域請(qǐng)求數(shù)據(jù)cookie丟失問(wèn)題
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢(xún)回復(fù)僅供參考,敬請(qǐng)考生以權(quán)威部門(mén)公布的正式信息和咨詢(xún)?yōu)闇?zhǔn)!
相關(guān)閱讀網(wǎng)頁(yè)制作
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡(jiǎn)要咨詢(xún) | 簡(jiǎn)要咨詢(xún)須知 | 新媒體/短視頻平臺(tái) | 手機(jī)站點(diǎn)

版權(quán)所有:易賢網(wǎng)