The remote XML API is not on the same domain as your page, is it? Then you
can't do it. Browser cross-domain restrictions will not permit it.

The only reason you can use getJSON for cross-domain requests is that it
actually downloads executable JavaScript code with a dynamic <script>
element, i.e. the "JSONP" format - and that only works with servers that
support JSONP.

To use an XML REST API from another domain in your JavaScript code, you will
need to put a proxy of some sort on your server, so that you can make the
request to your own domain. This can be as simple as a few lines of PHP code
- search for something like "php proxy" for some examples.

-Mike

On Mon, Jan 4, 2010 at 1:06 PM, Simon <simon....@rewardstream.com> wrote:

> Hi there.
>
> I'd like to use jQuery to access a remote website that has a REST API
> which returns XML data.
>
> Should I be able to use the jQuery.getJSON request to do it or is
> there another command since it's returning XML.
>
> Example Request Details (HTTP GET):
>
> https://{username}:{passwo...@api.opsourcecloud.net/oec/0.9/myaccount<http://username%7D:%7bpassword...@api.opsourcecloud.net/oec/0.9/myaccount>
>
> Example Response Details:
>
> <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
> <ns3:Account xmlns:ns2="http://oec.api.opsource.net/schemas/
> organization" .. >
> <ns3:userName>rdyer</ns3:userName>
> <ns3:fullName>Joe Public</ns3:fullName>
> <ns3:firstName>Joe</ns3:firstName>
> <ns3:lastName>Public</ns3:lastName>
> <ns3:emailAddress>jpublic24...@pop.net</ns3:emailAddress>
> <ns3:orgId>1831c1a9-9c03-44df-a5a4-f2a4662d6bde</ns3:orgId>
> <ns3:roles>
> <ns3:role>
> <ns3:name>primary administrator</ns3:name>
> </ns3:role>
> </ns3:roles>
> </ns3:Account>
>

Reply via email to