front-end-notes icon indicating copy to clipboard operation
front-end-notes copied to clipboard

ajax跨域请求

Open zstao opened this issue 10 years ago • 1 comments

之前utils.js中的ajax是不是不支持跨域请求,www.51zhiquan.com请求dev.51zhiquan.com下的内容时Request Method 变成了OPTIONS 1 2

zstao avatar Aug 20 '15 16:08 zstao

删除ajax方法中GET请求下的缓存header即可访问,具体原理不清楚。。

if (type == "GET" || type == "get" || type == null) {
        xhr.open(type, url + '?' + data, true);
        xhr.setRequestHeader("If-Modified-Since","0");   //删除此行
        xhr.send(null);
}

chenjiahan avatar Aug 21 '15 00:08 chenjiahan