一周前我有这个确切的代码工作,突然它停止工作。我认为 bing 的 api 没有任何变化,我检查了我的帐户,仍然有很多搜索。我什至在提琴手中模仿了这个确切的请求并且它有效。这是我的代码:
function queryBing(query, start, callback) {
var requestStr = "https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Image?Query=%27" + query + "%27&$top=50&$format=json&ImageFilters=%27Size%3aMedium%27&Adult=%27Moderate%27";
console.log(requestStr);
console.log(accountKeyEncoded);
jQuery.support.cors = true;
$.ajax({
url: requestStr,
beforeSend: function (xhr) {
xhr.setRequestHeader('Authorization', 'Basic ' + accountKeyEncoded);
},
context: this,
dataType: "json",
type: 'GET',
error: function(e){
e.Message;
},
success: callback
});
}
并返回以下错误:
OPTIONS https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Image?Query=%27te…$top=50&$format=json&ImageFilters=%27Size%3aMedium%27&Adult=%27Moderate%27 Origin http://localhost:81 is not allowed by Access-Control-Allow-Origin. jquery.js:8706
XMLHttpRequest cannot load https://api.datamarket.azure.com/Data.ashx/Bing/Search/v1/Image?Query=%27te…$top=50&$format=json&ImageFilters=%27Size%3aMedium%27&Adult=%27Moderate%27. Origin http://localhost:81 is not allowed by Access-Control-Allow-Origin.
一周前,我已经能够从我的本地计算机和我的网站进行查询。我尝试查看我的帐户设置,但在 Bing 中找不到我可以添加我的域的任何地方。