我想在数据库中添加数据,因为我希望ajax responce数组也在POST数组中但是没有这样做
<div class="form-group">
<label for="focusedinput" class="col-sm-2 control-label">Campus Accreditation</label>
<div class="col-sm-7">
<?php Web_Interface::load_accreditation($obj_admin->adminCountry); ?>
<script>
jQuery("input[id=accreditation]").click(function() {
var selectedCheckBoxArray = new Array();
var n = jQuery("input[id=accreditation]:checked").length;
if (n > 0) {
jQuery("input[id=accreditation]:checked").each(function() {
selectedCheckBoxArray.push($(this).val());
});
//send check box data value array to server using Ajax
var data = {
myCheckboxes: selectedCheckBoxArray
};
jQuery.ajax({
url: "../process/ProcessAjaxChecking.php",
data: data,
type: "POST",
success: function(data) {
$('#getAcademics').html(data);
$json = json_encode(data);
$.ajax({
url: "Example.php",
type: "POST",
dataType: "json",
success: function(msg) {
$('#getAcademics').html(data);
}
});
}
});
}
});
</script>
</div>
答案 0 :(得分:0)
在你的value.php中,你给出了名字&#39; academicsCheckBoxes and you have paased in ajax
myCheckboxes`。
更改强>
var data = {
academicsCheckBoxes: selectedCheckBoxArray
};
更新代码
<div class="form-group">
<label for="focusedinput" class="col-sm-2 control-label">Campus Accreditation</label>
<div class="col-sm-7">
<?php Web_Interface::load_accreditation($obj_admin->adminCountry); ?>
<script>
jQuery("input[id=accreditation]").click(function() {
var selectedCheckBoxArray = new Array();
var n = jQuery("input[id=accreditation]:checked").length;
if (n > 0) {
jQuery("input[id=accreditation]:checked").each(function() {
selectedCheckBoxArray.push($(this).val());
});
//send check box data value array to server using Ajax
var data = {
academicsCheckBoxes: selectedCheckBoxArray
};
jQuery.ajax({
url: "../process/ProcessAjaxChecking.php",
data: data,
type: "POST",
success: function(data) {
$('#getAcademics').html(data);
$json = json_encode(data);
$.ajax({
url: "Example.php",
type: "POST",
dataType: "json",
success: function(msg) {
$('#getAcademics').html(data);
}
});
}
});
}
});
</script>
</div>