好吧,我似乎无法弄清楚为什么这不起作用。 (底部有错误描述)
<script type="text/javascript">
$(document).ready(function(){
$('#submit').click(function(){
$('input[type=checkbox]:checked').each(function(){
ajax=$.ajax({
type: "POST",
url: "rollcall_submitvote.php",
data: 'division='+ $(this).val,(),
cache: false
}
});
});
});
</script>
<?php
/**
* Include vB core.
*/
require_once('./global.php');
require_once(DIR . '/includes/functions_bigthree.php');
require_once(DIR . '/includes/functions_forumlist.php');
/**
* Grab the divisions from the database.
*/
$query = $db->query_read("SELECT division FROM rollcall_divisions");
while($array = $db->fetch_array($query)){
echo "<input type='checkbox' value=".$array[division].">".$array[division]."<br>";
}
?>
<input type="submit" id="submit">
这是提交投票页面:
<?php
/**
* Include vB core.
*/
require_once('./global.php');
require_once(DIR . '/includes/functions_bigthree.php');
require_once(DIR . '/includes/functions_forumlist.php');
$db->query_write("INSERT INTO rollcall_users VALUES ('".$_POST["division"]."', '".$vbulletin->userinfo['username']."')")or die(mysql_error());
?>
如果我转到提交投票页面,它会在数据库中放入一个空结果和用户名的记录。但如果我点击提交,则无法添加任何内容。
答案 0 :(得分:1)
$(document).ready(function(){
$('#submit').click(function(){
$('input[type=checkbox]:checked').each(function(){
ajax=$.ajax({
type: "POST",
url: "rollcall_submitvote.php",
data: 'division='+ $(this).val,(),
cache: false
});
});
});
});
没有看到错误消息,但您缺少);
来关闭ajax调用。