Reputation: 5549
From a webpage, I need to send JSON data using POST method to a different domain.
I can use a form with hidden fields, but then POST data is application/x-www-form-urlencoded instead of application/json, and is "name=value" instead of "value"
I can use XMLHttpRequest (directly or through any API) to send arbitrary JSON data in the POST payload, but then I run into cross-domain limitation.
Also, I need the browser to really navigate to the new url, because what we are really doing is to invoke a different application sending some parameters.
Any options?
Upvotes: 4
Views: 5961
Reputation: 34675
If you are limited to the browser, then no - there are no other options. Browsers cannot perform cross-domain POST
requests to arbitrary domains. This is a security feature.
If you have full control over the server (or if it's already configured for this), you might consider CORS, but this feature is not strongly supported yet.
Upvotes: 2