JSON (仅限本地)

  <script type="text/javascript">  
setInterval(function() {
    $("#content").load(location.href+" #content>*","");
}, 2000);
</script>
  <script type="text/javascript">
var xmlhttp = new XMLHttpRequest();
var url = "http://www.weather.com.cn/data/sk/101110101.html";

xmlhttp.onreadystatechange=function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
        myFunction(xmlhttp.responseText);
    }
}
xmlhttp.open("post", url, true);
xmlhttp.send();

function myFunction(response) {

  obj = JSON.parse(response);
  document.getElementById("demo").innerHTML =
  obj.weatherinfo.city + " " + obj.weatherinfo.cityid;
}

</script>

  <i id="demo">

 

 

{"weatherinfo":{"city":"西安","cityid":"101110101","temp":"7","WD":"东风","WS":"2级","SD":"21%","WSE":"2","time":"15:00","isRadar":"1","Radar":"JC_RADAR_AZ9290_JB","njd":"27400","qy":"985"}}

posted @ 2015-02-04 16:14  G-Beniot  阅读(193)  评论(0编辑  收藏  举报