Get JSON data across domains

Source: Internet
Author: User

This is the weather JSON data, here is the link, JSON data interface http://m.weather.com.cn/data/101010100.html

Data format for JSON

{"Weatherinfo": {"City": "Beijing", "city_en": "Beijing", "date_y": "March 4, 2014", "date": "", "Week": "Tuesday", "Fchh": "11", " Cityid ":" 101010100 "," Temp1 ":" 8℃~-3 ℃ "," Temp2 ":" 8℃~-3℃ "," Temp3 ":" 7℃~-3℃ "," Temp4 ":" 8℃~-1 ℃ "," TEMP5 ":" 10℃~1℃ "," Temp6 ":" 10℃~2℃ "," tempF1 ":" 46.4℉~26.6℉ "," tempF2 ":" 46.4℉~26.6℉ "," tempF3 ":" 44.6℉~26.6℉ "," tempF4 ":" 46.4℉~30.2℉ "," TempF5 ":" 50℉~33.8℉ "," tempF6 ":" 50℉~35.6℉ "," Weather1 ":" Sunny "," weather2 ":" Sunny "," Weather3 ":" Sunny "," weather4 ":" Sunny Turn Cloudy "," Weather5 ":" Cloudy "," Weather6 ":" Cloudy "," IMG1 ":" 0 "," img2 ":" "," IMG3 ":" 0 "," IMG4 ":" The "," Img5 ":" 0 "," img6 ":" The "," Img7 ":" 0 " , "Img8": "1", "IMG9": "1", "IMG10": "The", "Img11": "1", "Img12": "", "Img_single": "0", "img_title1": "Sunny", "img_title2": "Sunny "," Img_title3 ":" Sunny "," img_title4 ":" Sunny "," img_title5 ":" Sunny "," img_title6 ":" Sunny "," Img_title7 ":" Sunny "," Img_title8 ":" Cloudy "," img_ Title9 ":" Cloudy "," Img_title10 ":" Cloudy "," Img_title11 ":" Cloudy "," img_title12 ":" Cloudy "," Img_title_single ":" Sunny "," Wind1 ":" North wind 4-5 Turn Breeze "," wind2 ":" Breeze "," wind3 ":" Breeze "," Wind4 ":" Breeze "," Wind5 ":" Breeze "," Wind6 ":" Breeze "," fx1 ":" North Wind "," FX2 ":" Breeze "," FL1 ":" Level 4-5 to less than 3 "," FL2 ":" Less than 3 levels "," FL3 ":" Less than 3 levels "," FL4 ":" Less than 3 levels "," FL5 ":" Less than 3 levels "," fl6 ":" Less than 3 levels "," Index ":" Cold "," index_d ":" The cold weather, recommended thick down jacket, fur coats thicker sweater and other winter clothing. " In particular, the elderly should pay attention to warm frost. "," index48 ":" Cold "," index48_d ":" Cold weather, recommended cotton clothes, down jacket, leather jackets and sweaters and other winter clothing. " The frail and infirm are suitable for thick coat, winter coat or thick down jacket. "," Index_uv ":" Medium "," INDEX48_UV ":" moderate "," INDEX_XC ":" More Appropriate "," INDEX_TR ":" General "," Index_co ":" More Comfortable "," st1 ":" 7 "," St2 ":" 3 "," ST3 ":" 8 "," St4 ":" 0 "," st5 ":" 7 "," St6 ":" 1 "," INDEX_CL ":" Less suitable "," Index_ls ":" Basic Fit "," Index_ag ":" Easy Hair "}}

What is this, needless to say?

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title>json cross-Domain Solutions </title>
<script src= ' http://code.jquery.com/jquery-1.8.0.js ' type= ' Text/javascript ' ></script>
<script type= "Text/javascript" src= "Https://github.com/douglascrockford/JSON-js/blob/master/json2.js" >< /script>
<body>
<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) {
if (data.query.results) {
$ ("#content"). Text (Json.stringify (data.query.results));
var j_data = Json.parse (json.stringify (data.query.results));
alert (J_data.weatherinfo.city);

} else {
$ ("#content"). Text (' No such code: ' + code);
}
});
});
</script>
</body>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.