Cross-domain AJAX - will this method work?

I wondered a bit whether there is a way to get cross-domain AJAX (using XML, not JSON) to work. Can someone see the reason why the following will not work:

  • Create iframe
  • Load AJAX call url in iframe
  • Use JavaScript to get iframe content

(this will not be asynchronous, but can using setTimeout(functionToLoadTheIframe, 1) allow you to achieve asynchrony?)

+6
ajax cross-domain iframe
source share
3 answers

Yes, you can use iframes for cross domain AJAX. This gets a little complicated (moreover, if you want to use XML), but it is possible. Here is a good article describing several different hacks that are used. I think it is very similar to what you are describing. More importantly, it describes iframe rules for sharing iframes, which are likely to help the most.

http://softwareas.com/cross-domain-communication-with-iframes

+5
source share

iframes, where remote calls are used and "mimic" ajax, as we know it today, and the answer is YES ... you can use iframes, but you sometimes have to write the complex client side of the script using javaScript.

Have you considered using the server side script / application in your domain as a proxy server for a remote resource?

That is, send your requests to your script / application in your domain, which, in turn, will receive data / information from a remote host.

Yours faithfully,

+3
source share

This will not work due to the same domain security restriction. In most cases, you cannot interact with frames that have a different domain. Otherwise, a malicious site may, for example, download a mailbox.

+2
source share

All Articles