开发者

Is it viable to make cross-domain ajax requests within iframed content?

开发者 https://www.devze.com 2023-04-06 12:53 出处:网络
I have an application on one domain which needs to get data from an application on another domain. I would like to use an iframe based cross domain ajax tool such as porthole.js to implement the fol

I have an application on one domain which needs to get data from an application on another domain.

I would like to use an iframe based cross domain ajax tool such as porthole.js to implement the following:

  1. My application loads a page on the other server in an iframe.

  2. A message is sent using porthole to the iframe.

  3. The page on the other server check开发者_Go百科s to make sure the calling url is valid, and reads in the url of the ajax request it will make from the message.

  4. The remote page then uses the passed url to make an ajax request.

  5. The results are passed back to my application.

This solution lets me use the remote json data without systematically altering all of the services, which are built and managed by another team. If it doesn't work, I would work with them to use a system that uses porthole.js or jsonp for cross domain scripting.

The point that concerns me, though, is step 4. Does this count as an ajax call from the remote document inside the iframe, which would be able to make ajax calls against it, or does it count as a call from the outer window, which can't use ajax to call that domain?


Jeez, just use CORS. It's a one-line change to the web-server config.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号