重新加载div以重新加载XML

Inside of div#weather, I have some PHP that is calling an Google's weather XML. It works great, except that it gets stale. I'd like to reload the div every 600000 milliseconds to get fresh XML.

I was going down the path of a javascript timer, but that seems to require an external URL.

If I need to have the PHP in an external file, it's no big deal, just not ideal.

<div id="weather">
<?php
    $URL = "http://www.google.com/ig/api?weather=60618";
    $dataInISO = file_get_contents($URL);
    $dataInUTF = mb_convert_encoding($dataInISO, "UTF-8", "ISO-8859-2");
    $xml = simplexml_load_string($dataInUTF);
    $current = $xml->xpath("/xml_api_reply/weather/current_conditions");
?>
    <div class="weather-<?php $weather =  $current[0]->condition['data']; $weatherclass = str_replace(' ','-',$weather); $weatherclass = strtolower($weatherclass); echo $weatherclass; ?>">&nbsp;</div>
    <div id="temp"><?= $current[0]->temp_f['data'] ?>&deg;</div>
    <div id="condition"><?= $current[0]->condition['data'] ?></div>
</div>

If you want to keep your single file, you can use ajax to call itself and then just grab the html inside <div id="weather"> to replace your current div.

$.get('your current page.php', function(data){
   var a = $(data);
   var weather = $(a).find('#weather').html();
   $('#weather').html(weather);
});