jquery - XMLHttpRequest cannot load.... Origin null is not allowed by Access-Control-Allow-Origin -
i trying print json broker on server, can not return json, chorme me of following error:
xmlhttprequest can not load .... origin null not allowed access-control-allow-origin.
can me?
the following code:`
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 });`
normally problem uri of page file :/ /, problem disappears if execution done server, option start chrome - allow-file-access-from-files
Comments
Post a Comment