Eric
Eric

Reputation: 49

Cross-site XML access using javascript without server access

I asked a question earlier but did not word it correctly so it got brushed over.

Basically, I am creating a windows 7 gadget that will access XML data from www.weather.gov and display some current conditions.

        function weat()
        {

            var url = "http://www.weather.gov/xml/current_obs/KMSY.xml";


            source.open("GET", url, false);
            source.send(null);
            info = source.responseXML;

            document.write("<table border='1'>");
            var stuff = info.getElementsByTagName("temp_f");

            document.write("<tr><td>");
            document.write(stuff);
            document.write("</tr></td>");
            document.write("</table>");

        }

Basically I am trying to get this to work from my desktop, and I'm not totally sure what the problem is. I still think it is a cross-site problem, since stuff prints as undefined, but I'm not totally sure of that. If anyone could help me, I've been googling possible solutions for about 6 hours now and I'm getting pretty frustrated.

Upvotes: 1

Views: 392

Answers (2)

jiggy
jiggy

Reputation: 3826

You either need a server-side proxy or you need to find a weather service that supports JSONP

Upvotes: 1

Ghostoy
Ghostoy

Reputation: 2759

I'm not familiar with Gadget. But in desktop browsers, I'm afraid Same origin policy prevent from any cross domain access.

One exception is that in Chromium, local pages (file://) can access remote URL only if --disable-web-securities is set when starting Chromium in command line.

Upvotes: 0

Related Questions