Cross Domain Ajax Request with JQuery/PHP

前端 未结 6 574
南笙
南笙 2020-11-30 13:28

Help, if you can-

The situation:

http://foobar.com includes a remotely hosted javacript file (http://boobar.com/stuff.js).

The goal is to just get an

6条回答
  •  抹茶落季
    2020-11-30 13:40

    There is a method called window.name transport or window.name method which uses a general browser bug(not sure if this is a bug actually). You make the request through an iFrame and the loaded page puts the information you need to the "name" property of the JavaScript window object of itself.

    This method uses a "blank.htm" since it first navigates to the target page and then goes back to the blank.htm page to overcome the "same origin policy" restriction.

    Dojo have implemented this and you can find a more detailed explanation here.

    Also I have implemented a cross-domain XMLHttpRequest object based on this method in the library I have written which can be found here.

    You may not be able to use the library since it will need 1 or 2 additional libraries which can be found here.

    If you need further help in implementing it in your style, I'll try to do my best.

提交回复
热议问题