我正在从我的网页进行ajax调用,以获取JSON格式的getWeather.php页面的响应。有时候我会得到结果,但大多数时候我都没有。但每当我浏览此链接时,它总是以JSON格式给我结果。我在getWeather.php中做错了吗?
https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%27lahore%27)%20AND%20u%3D%27c%27&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=
getWeather.php实施:
<?php
$city = $_GET['city'];
echo file_get_contents("https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20weather.forecast%20where%20woeid%20in%20(select%20woeid%20from%20geo.places(1)%20where%20text%3D%27".$city."%27)%20AND%20u%3D%27c%27&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=");
?>
{&#34;查询&#34; {&#34;计数&#34;:0,&#34;创建&#34;:&#34; 2017-01-03T04:50:27Z&#34; &#34;朗&#34;:&#34;的en-US&#34;&#34;结果&#34;:空}}