javascript - AngularJS can't use Basic Authentication -


i've problem settings header. js script

var invocation = new xmlhttprequest();         var url = 'http://example.com/api/auth';         var handler = [];          if(invocation) {                 invocation.open('get', url, true);             invocation.setrequestheader('x-pingother', "ddd");             invocation.setrequestheader('access-control-allow-origin', "http://localhost");             invocation.setrequestheader('access-control-request-headers', true);             invocation.onreadystatechange = handler;             invocation.send();            } 

header firebug:

options /api/auth http/1.1 host: example.com user-agent: mozilla/5.0 (windows nt 6.2; wow64; rv:18.0) gecko/20100101 firefox/18.0  firephp/0.7.4 accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 accept-language: en-us,en;q=0.5 accept-encoding: gzip, deflate origin: http://localhost access-control-request-method: access-control-request-headers: access-control-allow-origin,x-pingother x-insight: activate connection: keep-alive 

as can see adds access-control-request-headers value, , sets options no get. idea?

you should use $http comes angularjs, better:

$http.defaults.usexdomain = true; //enable cors  $http({     method: 'get',      url: 'http://example.com/api/auth',      headers: {'x-pingother': 'ddd'}  }); 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -