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

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

缺少CORS標頭“ Access-Control-Allow-Origin”

缺少CORS標頭“ Access-Control-Allow-Origin”

UYOU 2019-10-21 10:02:39
我從我的asp.net表單調用此函數,并在調用ajax時在Firebug控制臺上收到以下錯誤。跨域請求被阻止:同源策略禁止讀取位于http://anotherdomain/test.json的遠程資源。(原因:CORS標頭“ Access-Control-Allow-Origin”缺失)。var url= 'http://anotherdomain/test.json';        $.ajax({            url: url,            crossOrigin: true,            type: 'GET',            xhrFields: { withCredentials: true },            accept: 'application/json'        }).done(function (data) {            alert(data);                        }).fail(function (xhr, textStatus, error) {            var title, message;            switch (xhr.status) {                case 403:                    title = xhr.responseJSON.errorSummary;                    message = 'Please login to your server before running the test.';                    break;                default:                    title = 'Invalid URL or Cross-Origin Request Blocked';                    message = 'You must explictly add this site (' + window.location.origin + ') to the list of allowed websites in your server.';                    break;            }        });我已經做了另一種方法,但仍然找不到解決方案。注意:我沒有更改服務器端(API / URL)的服務器權限。
查看完整描述

3 回答

  • 3 回答
  • 0 關注
  • 1132 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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