We have a scenario where we need to post data from our domain (x.com) to a different domain (y.com). The action on the y.com is attributed HTTPPost
and it can be changed. But while posting data to the y.com using AJAX
and JSONP
with HTTPMethod POST
the request is automatically converted to HTTPMethod GET
.
3 Answers
You can't POST using JSONP (look here and here) because it just doesn't work that way - it creates a <script>
element to fetch data, which has to be done via GET request. JSONP solution doesn't use XmlHttpRequest
object, so it is not an AJAX request in the standard way of understanding, but the content is still accessed dynamically - no difference for the end user.
JSONP can be indeed used to overcome same origin policy restriction, but alternatively you can use CORS, implemented in modern browsers alternative to JSON with Padding.
JSONP
request are GET
request and cannot be made with POST
requests. If you want to sent a post request look into Cross origin Resource Sharing.

- 96,336
- 17
- 118
- 137
As a work around what you can do is to resolve CrossDomain communication using postMessage which is a new feature of HTML5. However, in order for your to resolve it you will need to use iframes and in the case if you do not want to display some iframe, you can create it 1x1px with display:none css property. This will allow you to achieve your goal.

- 255
- 2
- 2