HTML页面中的Ajax语法错误

时间:2016-07-01 16:54:11

标签: ajax html5

晚上好,

我一直在尝试在html页面上实现此示例。如果我查看IE调试器,它会说我在第11行( var arr,i; )上有语法错误。也许,你知道我在剧本中做错了什么吗?

非常感谢您停止我的问题和时间。

祝福, 劳伦

<!DOCTYPE html>
<html>
<head>
<title>home</title>
<meta http-equiv="refresh" content="300">
<script type="text/javascript" src="scripts/date_time.js"></script>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=0"/>
<link rel="stylesheet" type="text/css" href="css/mystyle_day.css" />
<script>
$(document).ready(
var arr, i;
$.ajax({
method: "GET",
url: "json.php",
dataType: "json"
}).done(function( data ) {
arr = $.parseJSON(data);
i = 0;
$(':checkbox').each(function(){
    this.checked = arr[i++];  //assuming ajax file returned boolean values  in json array.
 });
}));
</script>
</head>
<body>
<input type="checkbox" name="vehicle" value="Bike"> I have a bike<br>
<input type="checkbox" name="vehicle" value="Car"> I have a car<br>
<input type="checkbox" name="vehicle" value="Truck"> I have a truck<br>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

您忘记将代码包含在回调函数中:

if (this.busy) return;
this.busy = true;
相关问题