samyak bhalerao
samyak bhalerao

Reputation: 307

How to make cross-domain ajax Post request using jquery?

I am trying to make ajax POST request but always get error as "Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at "myURL". This can be fixed by moving the resource to the same domain or enabling CORS." and "No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access." I am able to post data to server but can't get response from server.

Upvotes: 0

Views: 1623

Answers (2)

samyak bhalerao
samyak bhalerao

Reputation: 307

Limitations of making jsonp request is that we can perform only "GET" request to server.What I wanted was making cross domain "POST" request.I found one solution for such situations. Install xampp server create proxy server () deploy html project on proxy server and then make normal "POST" request using jquery.

Upvotes: 0

Ankur Aggarwal
Ankur Aggarwal

Reputation: 3101

Same origin policy is implemented by default and you should stick to it http://api.jquery.com/jQuery.ajax/.

However if you want to make cross-domain request you can do that through JSONP http://en.wikipedia.org/wiki/JSONP http://json-p.org/ . Type data:"jsonp" and you will get it. Make sure you actually needed this.

Upvotes: 2

Related Questions