var url= 'http://sample.net:8051/admin/singleprofile';
$.ajax({
url: url,
crossOrigin: true,
type: 'GET',
xhrFields: { withCredentials: true },
accept: 'application/json'
}).done(function (data) {
console.log(data);
}).fail(function (xhr, textStatus, error) {
var title, message;
switch (xhr.status) {
case 403:
title = xhr.responseJSON.errorSummary;
console.log('Please login to your server before running the test.');
break;
default:
title = 'Invalid URL or Cross-Origin Request Blocked';
console.log('You must explicitly add this site (' + window.location.origin + ') to the list of allowed websites in your server.');
break;
}
});
私は、問題の下に取得しています: あなたが明示的にリストにこのサイト(' + window.location.origin + ')
を追加する必要がありますあなたのサーバーの許可されたウェブサイト。クロスオリジン・リクエスト:同一生成元ポリシーは、HTTPでのリモートリソースを読んで禁止する:上記のコードから//sample.ent
エラーメッセージの内容を正確に実行する必要があります。発信元を許可されたCORSリストに追加して、ヘッダー 'Access-Control-Allow-Origin:http:// sample.net'がサーバーから送信されるようにします。 –