![](/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.