zoukankan      html  css  js  c++  java
  • 跨域使用jsonp 获取天气预报

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
      <title>注册</title>     
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <script type ="text/javascript" src="jquery.js"></script>    
    </head>
    <body>
    <script type="text/javascript" src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>   
    <div id="content">   
                  
              
    </div>   
       <script>
    $(function(){   
        $.getJSON("http://query.yahooapis.com/v1/public/yql", {   
        q: "select * from json where url='http://m.weather.com.cn/data/101010100.html'",   
        format: "json"   
    }, function(data) {   
        var $content = $("#content")   
        if (data.query.results) {  
            var result = JSON.stringify(data.query.results);
            $content.text(result);  
            var obj = eval('('+result+')');
            alert(obj.weatherinfo.city);
        else {   
            $content.text('no such code: ' + code);   
        }   
    });   
              
    });
    </script>
      
    </body>
    <script>
          
      
      
    </script>
    </html>
     
     
    http://www.webxml.com.cn/WebServices/WeatherWebService.asmx
     
  • 相关阅读:
    HDU 1087 Super Jumping! Jumping! Jumping!
    HDU 1159 Common Subsequence
    HDU 1003 Maxsum
    HDU 2604 Queuing
    HDU 2045 不容易系列之(3)—— LELE的RPG难题
    HDU 2501 Tiling_easy version
    HDU 2050 折线分割平面
    HDU 2018 母牛的故事
    HDU 2046 骨牌铺方格
    HDU 2044 一只小蜜蜂...
  • 原文地址:https://www.cnblogs.com/jazzka702/p/3340704.html
Copyright © 2011-2022 走看看