52,792
社区成员




<script type="text/javascript" src="jquery-3.1.0.min.js"></script>
<script>
$(function(){
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js',function(){
var url='https://api.heweather.com/x3/weather?city='+remote_ip_info.city+'&key=cc6b92d4bbd74ab5951b2a41bd10b7a3';
$.getJSON(url,function(json){
$('#city').html(json["HeWeather data service 3.0"][0].basic.city);//城市天气
$('#data').html(json["HeWeather data service 3.0"][0].basic.update.loc);//更新时间
$('#weather').html(json["HeWeather data service 3.0"][0].now.tmp);//当前温度
$('#airpoint').html(json["HeWeather data service 3.0"][0].aqi.city.aqi);//空气质量指数
$('#suggest').html(json["HeWeather data service 3.0"][0].suggestion.comf.txt);//天气简介
$('#station').html(json["HeWeather data service 3.0"][0].now.cond.txt);
});
});
});
</script>
<div id="city"></div>
<div id="data"></div>
<div id="weather"></div>
<div id="airpoint"></div>
<div id="suggest"></div>
<div id="station"></div>
[/quote]
<script type="text/javascript" src="jquery-3.1.0.min.js"></script>
<script>
$(function(){
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js',function(){
var url='https://api.heweather.com/x3/weather?city='+remote_ip_info.city+'&key=cc6b92d4bbd74ab5951b2a41bd10b7a3';
$.getJSON(url,function(json){
$('#city').html(json["HeWeather data service 3.0"][0].basic.city);//城市天气
$('#data').html(json["HeWeather data service 3.0"][0].basic.update.loc);//更新时间
$('#weather').html(json["HeWeather data service 3.0"][0].now.tmp);//当前温度
$('#airpoint').html(json["HeWeather data service 3.0"][0].aqi.city.aqi);//空气质量指数
$('#suggest').html(json["HeWeather data service 3.0"][0].suggestion.comf.txt);//天气简介
$('#station').html(json["HeWeather data service 3.0"][0].now.cond.txt);
});
});
});
</script>
<div id="city"></div>
<div id="data"></div>
<div id="weather"></div>
<div id="airpoint"></div>
<div id="suggest"></div>
<div id="station"></div>
<script type="text/javascript" src="jquery-3.1.0.min.js"></script>
<script>
$(function(){
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js',function(){
var url='https://api.heweather.com/x3/weather?city='+remote_ip_info.city+'&key=cc6b92d4bbd74ab5951b2a41bd10b7a3';
$.getJSON(url,function(json){
$('#city').html(json["HeWeather data service 3.0"][0].basic.city);//城市天气
$('#data').html(json["HeWeather data service 3.0"][0].basic.update.loc);//更新时间
$('#weather').html(json["HeWeather data service 3.0"][0].now.tmp);//当前温度
$('#airpoint').html(json["HeWeather data service 3.0"][0].aqi.city.aqi);//空气质量指数
$('#suggest').html(json["HeWeather data service 3.0"][0].suggestion.comf.txt);//天气简介
$('#station').html(json["HeWeather data service 3.0"][0].now.cond.txt);
});
});
});
</script>
<div id="city"></div>
<div id="data"></div>
<div id="weather"></div>
<div id="airpoint"></div>
<div id="suggest"></div>
<div id="station"></div>
[/quote]
<script type="text/javascript" src="jquery-3.1.0.min.js"></script>
<script>
$(function(){
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js',function(){
var url='https://api.heweather.com/x3/weather?city='+remote_ip_info.city+'&key=cc6b92d4bbd74ab5951b2a41bd10b7a3';
$.getJSON(url,function(json){
$('#city').html(json["HeWeather data service 3.0"][0].basic.city);//城市天气
$('#data').html(json["HeWeather data service 3.0"][0].basic.update.loc);//更新时间
$('#weather').html(json["HeWeather data service 3.0"][0].now.tmp);//当前温度
$('#airpoint').html(json["HeWeather data service 3.0"][0].aqi.city.aqi);//空气质量指数
$('#suggest').html(json["HeWeather data service 3.0"][0].suggestion.comf.txt);//天气简介
$('#station').html(json["HeWeather data service 3.0"][0].now.cond.txt);
});
});
});
</script>
<div id="city"></div>
<div id="data"></div>
<div id="weather"></div>
<div id="airpoint"></div>
<div id="suggest"></div>
<div id="station"></div>
[/quote]
<script type="text/javascript" src="jquery-3.1.0.min.js"></script>
<script>
$(function(){
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js',function(){
var url='https://api.heweather.com/x3/weather?city='+remote_ip_info.city+'&key=cc6b92d4bbd74ab5951b2a41bd10b7a3';
$.getJSON(url,function(json){
$('#city').html(json["HeWeather data service 3.0"][0].basic.city);//城市天气
$('#data').html(json["HeWeather data service 3.0"][0].basic.update.loc);//更新时间
$('#weather').html(json["HeWeather data service 3.0"][0].now.tmp);//当前温度
$('#airpoint').html(json["HeWeather data service 3.0"][0].aqi.city.aqi);//空气质量指数
$('#suggest').html(json["HeWeather data service 3.0"][0].suggestion.comf.txt);//天气简介
$('#station').html(json["HeWeather data service 3.0"][0].now.cond.txt);
});
});
});
</script>
<div id="city"></div>
<div id="data"></div>
<div id="weather"></div>
<div id="airpoint"></div>
<div id="suggest"></div>
<div id="station"></div>
<script src="jquery-1.7.1.min.js"></script>
<script>
$(function(){
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js',function(){
var url='https://api.heweather.com/x3/weather?city='+remote_ip_info.city+'&key=cc6b92d4bbd74ab5951b2a41bd10b7a3';
$.getJSON(url,function(json){
$('#city').html(json["HeWeather data service 3.0"][0].basic.city);//城市天气
$('#data').html(json["HeWeather data service 3.0"][0].basic.update.loc);//更新时间
$('#weather').html(json["HeWeather data service 3.0"][0].now.tmp);//当前温度
$('#airpoint').html(json["HeWeather data service 3.0"][0].aqi.city.aqi);//空气质量指数
$('#suggest').html(json["HeWeather data service 3.0"][0].suggestion.comf.txt);//天气简介
$('#station').html(json["HeWeather data service 3.0"][0].now.cond.txt);
});
});
});
</script>
<div id="city"></div>
<div id="data"></div>
<div id="weather"></div>
<div id="airpoint"></div>
<div id="suggest"></div>
<div id="station"></div>
http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js
看看有没有返回值,实在不行你就把 $.getScript 改成同步的 ajax 请求。
你直接在浏览器中访问这个接口
http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js
看看有没有返回值,实在不行你就把 $.getScript 改成同步的 ajax 请求,这个接口返回的本来就是 json,用$.getScript 干什么。$(document).ready(function() {
var strCity;
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', function(){
strCity=remote_ip_info.city;
var url='https://api.heweather.com/x3/weather?city='+strCity+'&key=cc6b92d4bbd74ab5951b2a41bd10b7a3';
$.getJSON(url,function(json){
$('#city').html(json["HeWeather data service 3.0"][0].basic.city);//城市天气
$('#data').html(json["HeWeather data service 3.0"][0].basic.update.loc);//更新时间
$('#weather').html(json["HeWeather data service 3.0"][0].now.tmp);//当前温度
$('#airpoint').html(json["HeWeather data service 3.0"][0].aqi.city.aqi);//空气质量指数
$('#suggest').html(json["HeWeather data service 3.0"][0].suggestion.comf.txt);//天气简介
$('#station').html(json["HeWeather data service 3.0"][0].now.cond.txt);
});
});
});
$(document).ready(function() {
var strCity;
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', function(){
strCity=remote_ip_info.city;
var url='https://api.heweather.com/x3/weather?city='+strCity+'&key=cc6b92d4bbd74ab5951b2a41bd10b7a3';
console.log(url);
$.getJSON(url,function(json){
console.log(json);
});
});
});
$(document).ready(function() {
var strCity;
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', function(){
strCity=remote_ip_info.city;
var url='https://api.heweather.com/x3/weather?city='+strCity+'&key=cc6b92d4bbd74ab5951b2a41bd10b7a3';
$.getJSON(url,function(json){
$('#city').html(json["HeWeather data service 3.0"][0].basic.city);//城市天气
$('#data').html(json["HeWeather data service 3.0"][0].basic.update.loc);//更新时间
$('#weather').html(json["HeWeather data service 3.0"][0].now.tmp);//当前温度
$('#airpoint').html(json["HeWeather data service 3.0"][0].aqi.city.aqi);//空气质量指数
$('#suggest').html(json["HeWeather data service 3.0"][0].suggestion.comf.txt);//天气简介
$('#station').html(json["HeWeather data service 3.0"][0].now.cond.txt);
});
});
});
$(document).ready(function() {
var strCity;
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', function(){
strCity=remote_ip_info.city;
var url='https://api.heweather.com/x3/weather?city='+strCity+'&key=cc6b92d4bbd74ab5951b2a41bd10b7a3';
console.log(url);
$.getJSON(url,function(json){
console.log(json);
});
});
});
$(document).ready(function() {
var strCity;
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', function(){
strCity=remote_ip_info.city;
var url='https://api.heweather.com/x3/weather?city='+strCity+'&key=cc6b92d4bbd74ab5951b2a41bd10b7a3';
$.getJSON(url,function(json){
$('#city').html(json["HeWeather data service 3.0"][0].basic.city);//城市天气
$('#data').html(json["HeWeather data service 3.0"][0].basic.update.loc);//更新时间
$('#weather').html(json["HeWeather data service 3.0"][0].now.tmp);//当前温度
$('#airpoint').html(json["HeWeather data service 3.0"][0].aqi.city.aqi);//空气质量指数
$('#suggest').html(json["HeWeather data service 3.0"][0].suggestion.comf.txt);//天气简介
$('#station').html(json["HeWeather data service 3.0"][0].now.cond.txt);
});
});
});
像这样getjson还是得不到url的数据$(document).ready(function() {
var strCity;
$.getScript('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js', function(){
strCity=remote_ip_info.city;
var url='https://api.heweather.com/x3/weather?city='+strCity+'&key=cc6b92d4bbd74ab5951b2a41bd10b7a3';
$.getJSON(url,function(json){
$('#city').html(json["HeWeather data service 3.0"][0].basic.city);//城市天气
$('#data').html(json["HeWeather data service 3.0"][0].basic.update.loc);//更新时间
$('#weather').html(json["HeWeather data service 3.0"][0].now.tmp);//当前温度
$('#airpoint').html(json["HeWeather data service 3.0"][0].aqi.city.aqi);//空气质量指数
$('#suggest').html(json["HeWeather data service 3.0"][0].suggestion.comf.txt);//天气简介
$('#station').html(json["HeWeather data service 3.0"][0].now.cond.txt);
});
});
});
像这样 错在哪里?getjson中还是得不到url的数据