Ajax - send POST request with angularJS despite same-origin policy

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

Is there a way to send a POST request using AngularJS despite the same-origin policy? I don t need to get the response from the request, I just need to send the request. Just like creating a form and sending it to another server.

Thanks

Answers

You can use JSONP to send a request to another domain, however you can t use POST, it would have to be a GET request. Can you serialize your form values and send using GET?

http://docs.angularjs.org/api/ng.%24http#jsonp http://docs.angularjs.org/api/ng.%24http#jsonp

http://stackoverflow.com/questions/4508198/how-to-use-type-post-in-jsonp-ajax-call http://stackoverflow.com/questions/4508198/how-to-use-type-post-in-jsonp-ajax-call

Keep in mind that if you do use GET, you are limited with how much data you send, since URLs usually can t be over ~2000 characters.

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/15785935/send-post-request-with-angularjs-despite-same-origin-policy

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils