Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jquery在工作网络上不工作?_Jquery_Networking - Fatal编程技术网

jquery在工作网络上不工作?

jquery在工作网络上不工作?,jquery,networking,Jquery,Networking,我的网站上有以下代码来显示天气信息。直到最近,它一直运作良好。除了我上班的时候,它在任何地方都能用。工作时,它在我的工作电脑或手机上不工作,但在其他任何地方都能工作。我工作的时候,它曾经起作用。我们有一个声波墙在工作,但我的电脑是豁免它。我的站点上还有其他jquery仍在运行。有什么想法吗 <script> jQuery(document).ready(function($) { jQuery.ajax({ url : "http://api.wunderg

我的网站上有以下代码来显示天气信息。直到最近,它一直运作良好。除了我上班的时候,它在任何地方都能用。工作时,它在我的工作电脑或手机上不工作,但在其他任何地方都能工作。我工作的时候,它曾经起作用。我们有一个声波墙在工作,但我的电脑是豁免它。我的站点上还有其他jquery仍在运行。有什么想法吗

<script>
   jQuery(document).ready(function($) {
   jQuery.ajax({
   url :     "http://api.wunderground.com/api//conditions/forecast/q/autoip.json",
   dataType : "jsonp",
   success : function(parsed_json) { 
   var temp_f = parsed_json['current_observation']['temp_f'];
   var feelslike = parsed_json['current_observation']['feelslike_f'];
   var forecast = parsed_json['forecast']['txt_forecast']['date'];
   jQuery('#wg1').append(temp_f + " feels like " + feelslike);
     }
    });
   });
   setInterval(function refreshWeather() {
   jQuery(document).ready(function($) {
   jQuery.ajax({
   url : "http://api.wunderground.com/api//conditions/forecast/q/autoip.json",
   dataType : "jsonp",
   success : function(parsed_json) { 
   var temp_f = parsed_json['current_observation']['temp_f'];
   var feelslike = parsed_json['current_observation']['feelslike_f'];
   var forecast = parsed_json['forecast']['txt_forecast']['date'];
   jQuery('#wg1').html(temp_f + " feels like " + feelslike);
     }
    });
   });
   }, 900000);
</script>

从您的评论中,听起来好像parsed_json['current_observation']返回undefined,可能是因为parse_json不是您的代码所期望的

要进行故障排除,请添加console.logparsed_json作为success函数的第一行,并查看输出结果。通过这种方式,我们可以看到您从服务器得到了什么

您也可以尝试简单地将URL复制/粘贴到浏览器窗口中,然后从那里查看JSON:

我猜要么1 wunderground无法读取您的位置并返回JSON错误,要么2您的工作阻塞了URL,而您没有返回任何内容,或者返回了错误页面的HTML或其他内容。您将在console.log响应并手动检查时发现


编辑:如果wunderground返回一致的错误格式,请检查他们的API,您可以在尝试解析之前检查响应中的错误,从而使代码更加健壮。

在Chrome或Firefox中,有一些等效的开放式开发工具,刷新页面后查看网络和控制台选项卡。你有什么错误吗?是的,对不起,我以前没提过。它的内容是:UncaughtTypeError:无法读取undefinedok的属性'temp_f',Chrome开发工具提供了以下信息。这就是我需要寻找的吗?对象响应:对象错误:对象特性:对象术语服务:版本:0.1原型:对象定义设置:函数定义设置:函数定义设置:函数定义设置:函数查找设置:函数查找设置:函数查找设置:函数查找设置[native code]}构造函数:函数对象{[native code]}hasOwnProperty:函数hasOwnProperty{[native code]}isPrototypeOf:函数isPrototypeOf{[native code]}属性可枚举:函数属性可枚举{[native code]}toLocaleString:函数toLocaleString{[native code]}toString:函数toString{[native code]}valueOf:function valueOf{[native code]}get proto:function proto{[native code]}set\uu proto:function\uu proto{[native code]}谢谢詹姆斯。我的工作网络不允许“autoip”功能以某种方式工作。