JAVASCRIPT:点击按钮我想要执行以下操作:
group
PHP:此函数将接收值并将执行一些数据库操作。这里没有提到。
var paymentPeriodId = $('#paymentPeriodID').val();
if(paymentPeriodId < 1 ){alert('Payment period not set.');e.preventPropagation();return false; }
if(checkedRows.length < 1){alert('Supervisor not selected.');e.preventPropagation();return false; }
checkedRows = $.toJSON(checkedRows);
var formData = new FormData();
formData.append("paymentPeriodId", paymentPeriodId);
formData.append("checkedRows", checkedRows);
// alert(JSON.stringify(checkedRows));
alert(paymentPeriodId);
alert(checkedRows);
var qurl = '<?php echo base_url();?>salary_processing/summeriseProduction';
$.ajax({
url: qurl,
type: "POST",
data:formData,
success: function(data){
alert('successfull');
// var data = $.parseJSON(data);
// alert(JSON.stringify(data));
},
});
答案 0 :(得分:2)
var formData = new FormData();
var paymentPeriodId = $('#paymentPeriodID').val();
checkedRows = $.toJSON(checkedRows);
formData.append("paymentPeriodId", paymentPeriodId);
formData.append("checkedRows", checkedRows);
var qurl = '<?php echo base_url();?>salary_processing/summeriseProduction';
$.ajax({
url: qurl,
type: "POST",
data: formData,
success: function(data){}
试试这个
答案 1 :(得分:0)
var formData = new FormData();
var paymentPeriodId = $('#paymentPeriodID').val();
checkedRows = $.toJSON(checkedRows);
formData.append("paymentPeriodId", paymentPeriodId);
formData.append("checkedRows", checkedRows);
var qurl = '<?php echo base_url();?>salary_processing/summeriseProduction';
$.ajax({
url: qurl,
type: "POST",
processData: false,
contentType: false,
data: formData,
success: function(data){}
就像这样。