如何使用AJAX将复选框值发布到php脚本?
如何使用下面的命令将mysql中每个复选框的值插入新行或更新现有列,发送到php页面如何使用AJAX将复选框值发布到php脚本?,php,jquery,html,css,Php,Jquery,Html,Css,如何使用下面的命令将mysql中每个复选框的值插入新行或更新现有列,发送到php页面 <script language="javascript" type="text/javascript">// <![CDATA[ var $n = jQuery.noConflict(); //Jquery no conflict $n("#btnsubmit").click(function() { var allChkbox=$n('input
<script language="javascript" type="text/javascript">// <![CDATA[
var $n = jQuery.noConflict(); //Jquery no conflict
$n("#btnsubmit").click(function() {
var allChkbox=$n('input[name=cats[]]');
jQuery.each(allChkbox, function(i, singlecheckbox) {
alert(singlecheckbox.value+" is "+ singlecheckbox.value);
});
});
// ]]></script>
//
php将通过get接收请求
var $n = jQuery.noConflict(); //Jquery no conflict
$n("#btnsubmit").click(function() {
var allChkbox=$n('input[name=cats[]]');
var data = [];
jQuery.each(allChkbox, function(i, singlecheckbox) {
data[singlecheckbox.value] = singlecheckbox.value; // this line is strange, the index seems not be singlecheckbox.value
// alert(singlecheckbox.value+" is "+ singlecheckbox.value);
});
$.ajax({type:"GET", url: "test.php", data: data,
success:function(records){}, error: function(request, status, err){}});
});