AJAX cross domain call

前端 未结 11 940
温柔的废话
温柔的废话 2020-11-22 03:43

I know about AJAX cross-domain policy. So I can\'t just call \"http://www.google.com\" over a ajax HTTP request and display the results somewhere on my site.

I tried

11条回答
  •  遥遥无期
    2020-11-22 04:05

    after doing some research, the only "solution" to this problem is to call:

    if($.browser.mozilla)
       netscape.security.PrivilegeManager.enablePrivilege('UniversalBrowserRead');
    

    this will ask an user if he allows a website to continue. After he confirmed that, all ajax calls regardless of it's datatype will get executed.

    This works for mozilla browsers, in IE < 8, an user has to allow a cross domain call in a similar way, some version need to get configured within browser options.

    chrome/safari: I didn't find a config flag for those browsers so far.

    using JSONP as datatype would be nice, but in my case I don't know if a domain I need to access supports data in that format.

    Another shot is to use HTML5 postMessage which works cross-domain aswell, but I can't afford to doom my users to HTML5 browsers.

提交回复
热议问题