我一直在环顾四周,试图弄清楚如何通过 ajax 在页面上传递 2 个变量,此时我有一个页面,其中一个复选框 dynamailcy 在单击它时将其值保存到数据库中,但我需要它能够仅在此刻编辑具有 certian id 的行,我已经走到了这一步,但我被卡住了。任何帮助将不胜感激
$(function()
{
$("input[type='checkbox']").on('click', function(){
var chkName = $(this).attr('checked');
if($(this).is(":checked")) {
var checkVal = $(':checkbox[checked='+chkName+']').attr('value');
}
else{
var checkVal =$("#frm input:checkbox").attr("id");
}
var userid = $(':checkbox[checked='+chkName+']').attr('name');
$.ajax({
type: "GET",
url: 'request.php?uname=' + checkVal '&id'= + userid ,// this is where i cant send the &id varible across but i can send the checkVal
success: function(data) {
if(data == 1){//Succues
alert('Data was saved in db!');
}
if(data == 0){//Faliure
alert('Data was NOT saved in db!');
}
}
});
});
});
</script>
</head><body>
<div class="content">
<table border="0.02px" class="mytable">
<thead>
<th><strong>Paid</strong></th>
<th><strong>Repaired</strong></th>
<th><strong>Returned</strong></th>
</thead>
<tr>
<form id="frm" name="frm">
<td><input type="checkbox" value="Paid" id="Waiting on Payment" name="29" /></td>
<td><input type="checkbox" value="Repaired" id="Waiting on Repairs" name="uname" /></td>
<td><input type="checkbox" value="With Student" id="Awaiting Pickup" name="uname" /></td>
</form>
</tr>
</table>
</div>