javascript - CORS error in AngularJS -


when using fiddler or browser side http client extension advanced rest client, can data api easily. when try use same api angular js, cors issue appear immediately. have tried following lines solve problem in angularjs, unfortunately did not work.

appd.config(function ($httpprovider) {   //  $httpprovider.defaults.headers.post['content-type'] = 'application/x-www-form-urlencoded';     // $httpprovider.defaults.headers.post['accept'] = '*/*'     $httpprovider.defaults.usexdomain = true;     $httpprovider.defaults.withcredentials = true;     delete $httpprovider.defaults.headers.common["x-requested-with"];     $httpprovider.defaults.headers.common["accept"] = "*/*";     $httpprovider.defaults.headers.common["content-type"] = "application/x-www-form-urlencoded";     $httpprovider.defaults.headers.common['authorization'] = 'basic encodedpassword='; });  

i following error in mozilla:

cross-origin request blocked:

the same origin policy disallows reading remote resource @ http://host/training_webapi. can fixed moving resource same domain or enabling cors. 

and following in chrome:

 xmlhttprequest cannot load http://host/training_webapi request redirected 'http:host/training_webapi/', disallowed cross-origin requests require preflight. 

the service requesting not allowing cors (no access-control sent part of response). need include header access-control-allow-origin: * part of response (which not).

see : http://www.html5rocks.com/en/tutorials/cors/


Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -