Running a query and retrieving XML from an external site

三世轮回 提交于 2020-01-07 05:21:09

问题


I am trying to use Ajax to submit a query to an external database (http://foreignserver:1234/database?query="SELECT FROM WHERE"). The query will run and create an XML file which I would like to be returned. The external server is running on Apache Tomcat. I have done some research on cross-site scripting, but:

-CORS is not an option because IE7 has to be supported. It also seems unnecessarily difficult to do in Tomcat.

-easyXDM is not an option.

-I am trying to do this with XML, and JSONP seems to be a JSON thing?

-There will be a lot of data coming back, so iFrames probably are not an option.

What to do?


回答1:


  • JSONP would be better for this task as JSON syntax is light especially if you have a lot of data. Also, JSONP already bypasses SOP and is purely client-side, besides the fact that the server encodes the data as JSON. However, you'd have to use JSON instead of XML.

  • If you really insist using XML, you can have your server assist you to fetch the remote page. This means the browser at your domain requests the page from your server on the same domain, then your server reads the remote page and returns it to the browser. Your server will be a proxy that bypasses SOP.



来源:https://stackoverflow.com/questions/11195674/running-a-query-and-retrieving-xml-from-an-external-site

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!