0
我想使用JSONP請求另一個域上的飼料。我知道內容類型應該是JSON或JavaScript,但是它是text/plain,並且我無法控制服務器,因此我無法更改標題。我如何獲得AJAX呼叫的工作?請求JSONP與文本/普通的MIME類型
這裏是我迄今爲止 -
function asdf() {
$.ajax({
url: "http://example.com/path/to/sharepoint/_vti_bin/listdata.svc/TestCalendar/$count",
jsonp: "callback",
dataType: "jsonp",
contentType: "text/plain",
// work with the response
success: function(response) {
console.log(response); // server response
}
});
}
如果我只是嘗試有規律的要求,很明顯,我只是得到一個CORS錯誤。
XMLHttpRequest無法加載http://example.com/path/to/sharepoint/_vti_bin/listdata.svc/TestCalendar/ $ count。請求的資源上沒有「Access-Control-Allow-Origin」標題。因此不允許訪問原產地'http://example.com'。響應有HTTP狀態代碼401