![](/img/trans.png)
[英]Zillow API Error:“No 'Access-Control-Allow-Origin' header is present”
[英]No 'Access-Control-Allow-Origin' header is present error using bigcommerce api mvc
我正在使用大型商務API來獲取訂單清單,我嘗試了很多解決方案。
這是我面臨的錯誤..
api.bigcommerce.com/stores/4jwabif3gj/v2/orders.json?search=false&nd=1541740677952&rows=20&page=1&sidx=&sord=asc:1無法加載資源:服務器的響應狀態為401(未經授權)索引:1從來源' http:// localhost:62797 '在' https://api.bigcommerce.com/stores/4jwabif3gj/v2/orders.json?search=false&nd=1541740677952&rows=20&page=1&sidx=&sord=asc '訪問XMLHttpRequest已被CORS政策阻止:對預檢請求的響應未通過訪問控制檢查:所請求的資源上沒有“ Access-Control-Allow-Origin”標頭。
HTML
<table id="JqGrid"></table>
<div id="JqGridPager"></div>
jQuery的
<script type="text/javascript">
jQuery(document).ready(function ($) {
var $grid = $("#JqGrid");
$grid.jqGrid({
url: 'https://api.bigcommerce.com/stores/4jwabif3gj/v2/orders.json',
ajaxGridOptions: { xhrFields: { withCredentials: true } },
dataType: 'json',
colNames: ['id', 'date_created', 'date_modified', 'date_shipped', 'status'],
colModel: [
{ name: 'id', index: 'id', width: 10 },
{ name: 'date_created', index: 'date_created', width: 50, sorttype: 'date', datefmt: 'Y-m-d' },
{ name: 'date_modified', index: 'date_modified', width: 50, sorttype: 'date', datefmt: 'Y-m-d' },
{ name: 'date_shipped', index: 'date_shipped', width: 50, sorttype: 'date', datefmt: 'Y-m-d' },
{ name: 'status', index: 'status', width: 50 },
],
caption: "Order list",
pager: "#JqGridPager",
loadBeforeSend: function (jqXHR) {
jqXHR.setRequestHeader("X-Auth-Token", 'modebafppdxh9sd90zffehu9wwgpj3d', "X-Auth-Client", '535bnhhfkqblu7ebg1aq9r6kue1lgv6');
},
//ajaxGridOptions: {
// beforeSend: function (xhr) {
// xhr.setRequestHeader("X-Auth-Token", "modebafppdxh9sd90zffehu9wwgpj3d", "X-Auth-Client", "535bnhhfkqblu7ebg1aq9r6kue1lgv6");
// }
//},
viewrecords: true,
width: 1100,
height: 400
});
$grid.jqGrid('navGrid', '#JqGridPager', { edit: false, add: false, del: false })
});
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.