我在写一个chrome插件,用来做某个网站的查词翻译,现在需要调用扇贝的api
用原生js写的ajax:
var url = "https://api.shanbay.com/bdc/search/?word=dog"; var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { var res = JSON.parse(xmlhttp.responseText); console.log(res); } }; xmlhttp.open("GET", url); xmlhttp.send();
每次查询的时候就会报错
XMLHttpRequest cannot load https://api.shanbay.com/bdc/s... No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'chrome-extension://coknhbkedmkppmjkdjfkbcndclocbbnh' is therefore not allowed access.
昨天调用的时候还没有任何问题
请问该如何解决
慕婉清6462132
相关分类