简体   繁体   中英

Running a query and retrieving XML from an external site

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?

  • 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM