jQuery跨域訪問方式提示XMLHttpRequest cannot load

分類:IT技術 時間:2016-10-16
$(function($){
 var url = 'http://www.netpc.com.cn/weather/index';
 $.ajax(url, {
 data: {
 'cityname': '北京',
 'dtype': 'jsonp',
 'key': 'xxxx',
 '_': new Date().getTime()
 },
 dataType: 'jsonp',
 crossDomain: true,
 success: function(data) {
 if(data && data.resultcode == '200'){
 console.log(data.result.today);
 }
 }
 });

var url2 = 'http://www.netpc.com.cn/weather/index?callback=?';
 $.getJSON(url2, {
 'cityname': '上海',
 'dtype': 'jsonp',
 'key': 'xxxx',
 '_': new Date().getTime()
 }, function(data){
 if(data && data.resultcode == '200'){
 console.log(data.result.today);
 }
 });

var url3 = 'http://www.netpc.com.cn/weather/index?callback=?';
 $.get(url3, {
 'cityname': '香港',
 'dtype': 'jsonp',
 'key': 'xxxx',
 '_': new Date().getTime()
 }, function(data){
 if(data && data.resultcode == '200'){
 console.log(data.result.today);
 }
 }, 'json');
 });

Tags: function success cannot 北京 香港

文章來源:


ads
ads

相關文章
ads

相關文章

ad