I have the following setup:
www.domain1.com/page1/
-- makes ajax POST request to www.domain1.com/page2/
www.domain1.com/page2/
-- returns json response
www.domain2.com/page1/
-- embeds www.domain1.com/page1/
in iframe
When I load www.domain1.com/page1/
the ajax request is made and everything works. When I load www.domain2.com/page1/
in Chrome or Firefox, www.domain1.com/page1/
is displayed in the iframe, and the ajax request is made fine.
When I try to load www.domain2.com/page1/
in IE7 / IE8, the ajax request gives a FORBIDDEN error -- it seems to be treating the request as cross-domain and blocking it, even though the request is being made from www.domain1.com/page1/
to www.domain1.com/page2/
.
It works fine in IE when the request is GET, but not POST. How can I get IE to stop treating this as cross-domain, just because the entire flow is contained in an iframe?
Thanks!
jQuery v1.7.2 will fix CORS in IE, even if it isn't really CORS but IE thinks it is.
This simple boolean at the beginning of your JavaScript function should fix this behavior
$.support.cors = true;
This works for both GET and POST.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With