2
我想下面使用jQuery AJAX調用的URL訪問..如何使用CORS訪問Flipkart API?
Ajax調用
$.ajax({
type:"GET",
url: 'https://affiliate-api.flipkart.net/affiliate/report/orders/detail/xml?startDate=2015-05-01&endDate=2015-05-30&status=Pending&offset=0',
beforeSend: function(xhr) {
xhr.setRequestHeader("Fk-Affiliate-Id", "XXXXXX");
xhr.setRequestHeader("Fk-Affiliate-Token", "YYYYYYYYYYYYY");
},
success: function(data){
$('#response').html(data);
}
});
我得到下面的錯誤..
跨來源請求阻止:將同源策略不允許在https://affiliate-api.flipkart.net/affiliate/report/orders/detail/xml?startDate=2015-05-01&endDate=2015-05-30&status=Pending&offset=0處讀取遠程資源。 (原因:缺少CORS頭'Access-Control-Allow-Origin')。
跨域請求被阻止:同源策略不允許讀取遠端資源https://affiliate-api.flipkart.net/affiliate/report/orders/detail/xml?startDate=2015-05-01&endDate=2015-05-30&status=Pending&offset=0。 (原因:CORS請求失敗)。