当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Cross-domain AJAX With ActiveXObject on IE

问题描述:

Using the ActiveXObject object on IE. How can I submit a cross-domain request?

网友答案:

Setup a server-side proxy to make the request for you. Then invoke the proxy (locally) using AJAX.

网友答案:

I would really recommend using a javascript framework when dealing with ajax request. That way you don't have to get into the intricaties of each browser. My personal favorite is jQuery: http://www.jquery.com/

Now, when it comes to cross-domain, you have two situations:

  • Data is only available as XML => use a server-side proxy: http://ajaxpatterns.org/archive/Cross-Domain_Proxy.php
  • Data can be retrieved as JSON using JSONP: http://www.ibm.com/developerworks/library/wa-aj-jsonp1/

Whenever possible, when it comes to a web browser, I'd recommend JSONP for its simplicity. However, things can get tricky in case of error so, again for jQuery, I'd recommend the following plugin: http://code.google.com/p/jquery-jsonp/

分享给朋友:
您可能感兴趣的文章:
随机阅读: