Note that there are some explanatory texts on larger screens.

plurals
  1. POLocation aware and weather website. Problems with Javascript and cross site XML
    primarykey
    data
    text
    <p>Trying to make a page where it shows current weather to a user via Javascript. So I have code that can find a users location and properly create a URL that will fit the convention for Google's weather API perfectly but the problem is making the xml request and presenting the weather data back to the user is proving a problem. I have installed mod_rewrite for apache to get around the cross site xml problem however it doesn't seem to be working properly. Anyone else have and idea how I could get this to work? Here is the code I have so far:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta name="robots" value="none" /&gt; &lt;title&gt;&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;div id="yourinfo"&gt; &lt;/div&gt; &lt;b&gt;url:&lt;/b&gt; &lt;span id="url"&gt;&lt;/span&gt;&lt;br /&gt; &lt;b&gt;city:&lt;/b&gt; &lt;span id="city"&gt;&lt;/span&gt;&lt;br /&gt; &lt;script type="text/javascript" src="http://www.google.com/jsapi"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; if(google.loader.ClientLocation) { visitor_lat = google.loader.ClientLocation.latitude; visitor_lon = google.loader.ClientLocation.longitude; visitor_city = google.loader.ClientLocation.address.city; visitor_region = google.loader.ClientLocation.address.region; visitor_country = google.loader.ClientLocation.address.country; visitor_countrycode = google.loader.ClientLocation.address.country_code; weather_http = 'http://www.google.com/ig/api?weather=' + visitor_city + '+' + visitor_region; var Result = weather_http; } else { document.getElementById('yourinfo').innerHTML = '&lt;p&gt;Whoops!&lt;/p&gt;'; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.open("GET",'weather_http',false); xmlhttp.send(); xmlDoc=xmlhttp.responseXML; document.getElementById("url").innerHTML=weather_http document.getElementById("city").innerHTML=xmlDoc.getElementsByTagName("city")[0].childNodes[0].nodeValue; &lt;/script&gt; </code></pre> <p> </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload