0

There is an API on a domain. I have its URL and credentials. When I type the API URL in the browser, it displays data in the browser. Data is in XML format. I need to access that API using a function. How do I do that? Is there an issue of cross-domain? Coz I am accessing the from my server, which is on a different server. I need to capture that XML data and show it in HTML format. Please guide me on this.

In my opinion, I need to use XMLHttpRequest and/or JSONP and/or CORS. Kindly help.

1 Answers1

0

If you are just loading XML data to display the values in HTML then you should be able to use the get function from jQuery.

http://api.jquery.com/jQuery.get/

It may also help to encode the XML as JSON and use getJSON, but if you are unable to modify the web service this may not be an option.

http://api.jquery.com/jQuery.getJSON/

If you need to post things back to the API such as images and/or other files you will need to use JSONP or CORS. The web service will of course have to expect a JSON value, I would double check the API docs.