[英]alert not working not showing up
我輸入了一些代碼,以便可以測量位置的當前溫度。 我擁有允許我的用戶檢查位置但警報不起作用的腳本。
<h3> Weather Data </h3>
<form method="POST" action="about.php">
<input type="text" name="city" value= 'city'/>
<input type="submit" name="submit" value="submit" />
</form>
<?php
$city=$_POST['city'];
var_dump($city);
?>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script>
jQuery(document).ready(function($) {
$.ajax({
url : "http://api.wunderground.com/api/5e8af95dbdebbd73/geolookup/conditions/forecast/q/UK/<?php echo $city; ?>.json",
dataType : "jsonp",
success : function(parsed_json) {
var location = parsed_json['location']['city'];
var temp_f = parsed_json['current_observation']['temp_f'];
alert("Current temperature in " + location + " is: " + temp_f);
}
});
});
?>
</script>
警報應該會出現,但我做錯什么都沒有。
在關閉腳本標簽之前,您有一個不必要的關閉php標簽:
}
});
});
?> // this is a problem!
</script>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.