> I'm writing an OGC/WMS Viewer using jQuery.  One task I need 
> to accomplish involves making a getCapabilities request 
> against a Web Mapping Service, which responds with some XML.
> 
> I know that the $.ajax function allows me to get JSON from 
> another domain, but is there a way to get XML from another 
> domain?  I've tried various permutations of data types, and 
> the $.ajax call with the "jsonp" call gets closest--it 
> returns the XML, but since it's not true JSON, the browser complains.
> 
> Is my only option to use a proxy web service to access the XML?

Yes, that is your only option, unless the web mapping service has the option
to return JSONP (or any kind of executable JavaScript code) instead of XML.

XMLHttpRequest is limited to the same-domain rule.

Script tags/elements are not. You can load a script tag or element from any
URL.

Cross-domain JSONP is simply a way to wrap up JSON data inside a piece of
executable JavaScript code, so that it can be loaded in a script tag/element
instead of through XMLHttpRequest.

Do you need some code for a simple PHP proxy? It's only a few lines of code.
Give me a shout if you need it and I'll post the one I use - otherwise just
search for "php proxy" and you'll find some. Or you can find similar code
for any server language.

Just watch out that you don't run an open proxy inadvertently! Burn the
address of the web mapping service into the proxy server's requests, so
people can't use it for nefarious purposes.

-Mike

Reply via email to