Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

send POST request with angularJS despite same-origin policy

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

like image 577
Ephi Gabay Avatar asked Mar 05 '26 00:03

Ephi Gabay


1 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.$http#jsonp

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.

like image 60
jszobody Avatar answered Mar 06 '26 12:03

jszobody



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!