

前端:
以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
});服务器端:
以php为例:
header("Access-Control-Allow-Credentials: true");
header('Access-Control-Allow-Origin: http://m.z.com');根据自己的情况而定
上面是我整理给大家的,希望今后会对大家有帮助。
相关文章:
使用ajax实现无刷新改变页面内容和地址栏URL
JavaScript基于Ajax实现不刷新在网页上动态显示文件内容
AJAX对服务器返回XML的处理方法
