【发布时间】:2012-07-25 20:32:41
【问题描述】:
我正在尝试在复选框更改时创建表单提交 我的代码如下。 .我的问题是
gotofile.php
file but //dosomething 关于成功函数的执行
jquery:
$("#container input[type=checkbox]").change(function(e){
if($(this).attr('checked'))
{
var cnType=$(this).attr("id");
$.ajax({
type: "POST",
url: "gotofile.php",
data: "typID="+cnType ,
cache: false,
success: function(){
//do something
}
});
}
});
php:
include '../dbconnection/dbconfig.php';
$typeID=$_POST['typID'];
$qryConnections="INSERT INTO ...";
$rslt1 = mysql_query($qryConnections);
html
<form id="cnct" method="POST">
<div id="container" style="">
<ul style="list-style: none;">
<li><input type="checkbox" id="1" />A</li>
<li><input type="checkbox" id="2" />B</li>
</ul>
</div></form>
谁能帮我解决我做错了什么?
【问题讨论】:
-
你的 PHP 在做什么?它不输出任何东西。
-
你可能也想看看这个答案:stackoverflow.com/questions/901712/…
-
我也添加了 html 代码,我的 php 将值插入到数据库中
-
我得到了检查值,它的工作正常,只是 php postdosent 工作。我在 ajax 中做错了吗,因为我检查了 gotofile 放置虚拟值它工作正常
标签: php javascript jquery ajax checkbox