我正在尝试在我的服务器上打印该代理的 json,但我无法返回 json,这让我感到以下错误:
XMLHttpRequest 无法加载 .... Access-Control-Allow-Origin 不允许 Origin null。
有人能帮我吗?
以下代码:`
console.log("carregando..");
var username = "admin";
var password = "password";
$.ajax({
type: 'GET',
url: 'http://localhots/api/json/broker/dest-metrics',
dataType: 'json',
headers : {Accept : "application/json","Access-Control-Allow-Origin" : "*"},
beforeSend : function(req) {
req.setRequestHeader('Authorization', "Basic " +Base64.encode(username+":"+password))
console.log("Autenticado!!");
},
success: function(data) { console.log("Sucesso!!"); },
error: function (data) {
console.log("ERRO");
},
data: {},
async: false,
cache: false,
jsonp: true
});`