0

I have a form created in HTML that posts to an external domain

<form method="post" action="someExternalDomain.com/submit">

I want to submit it with this (I can't use JQuery because of the same-origin policy) but capture the response from the server using JQuery. How would I do this?

Thanks in advance.

Community
  • 1
  • 1
gtmtg
  • 3,010
  • 2
  • 22
  • 35
  • 2
    You can't post cross-domain without CORS, and jQuery can't access the response unless it is done with `jQuery.ajax` or an iframe, both of which are limited by the same-origin policy. – Kevin B Aug 15 '12 at 17:46
  • @KevinB So if the server implements CORS, will ```jQuery.ajax()``` or ```jQuery.post()``` be able to circumvent the same-origin policy? – gtmtg Aug 15 '12 at 17:54
  • 2
    Yes, though I believe it also takes some other modifications to make it work in all versions of IE. – Kevin B Aug 15 '12 at 17:56
  • 1
    @KevinB OK, thanks! Leave it to IE to cause problems :)... I found [this question](http://stackoverflow.com/questions/10232017/ie9-jquery-ajax-with-cors-returns-access-is-denied) which looks like it may help with that problem. Please post your comments as an answer so I can accept. – gtmtg Aug 15 '12 at 18:02

1 Answers1

2

You can't post cross-domain without CORS, and jQuery can't access the response unless it is done with jQuery.ajax or an iframe, both of which are limited by the same-origin policy.

If you do wish to implement CORS, it also takes some other modifications to make it work in all versions of IE.

Kevin B
  • 94,570
  • 16
  • 163
  • 180