<script type="text/javascript" src="jquery-1.3.2.js"></script>
<script>  
$(document).ready(function(){  
$.ajax({  
url: "http://m.weather.com.cn/data/101010100.html",  
cache: true,  success: function(js){  
//document.write(js.weatherinfo.city);  
var str = "<B>" + js.weatherinfo.city + "<B/><br/>" ;
 str +=js.weatherinfo.date_y + " " + js.weatherinfo.week + "<br/>";  
str += "农历:" + js.weatherinfo.date + "<br/>";  
str += "气温:" + js.weatherinfo.temp1 + "<br/>" ;
 str += "风力:" + js.weatherinfo.wind1 + "<br/>" ;
 str += "建议:" + js.weatherinfo.index_d + "<br/>" ;
 $("div").html(str) ;
 },  
dataType : "json"  });  
}) ;
 function dakai(){
 alert("in");
 }  
</script>  
   
  <body>
   <div id="results">  
</div>  
页面显示不出来 

解决方案 »

  1.   

    跨域了,
    在文件里没有跨域问题,
    但寄存在服务器上就不行了忘了jquery在哪个版本解决的json跨域问题,你可以试试下载最新版的jquery 1.7.2然后直接getJSON
      

  2.   

    然后直接getJSON
    直接在哪里get JSON
      

  3.   

    ...
    你的$.ajax({
    ...
    });
    改成$.getJSON(
      "http://m.weather.com.cn/data/101010100.html", 
      function(js){
        var str = "<B>" + js.weatherinfo.city + "<B/><br/>" ;
        str +=js.weatherinfo.date_y + " " + js.weatherinfo.week + "<br/>";  
        str += "农历:" + js.weatherinfo.date + "<br/>";  
        str += "气温:" + js.weatherinfo.temp1 + "<br/>" ;
        str += "风力:" + js.weatherinfo.wind1 + "<br/>" ;
        str += "建议:" + js.weatherinfo.index_d + "<br/>" ;
        $("div").html(str) ;
      }
    );
    前提是先升级你的jquery