我正在使用 custom_func 来验证编辑中的字段并添加以进行表单编辑。此 custom_func 正在对服务器进行 ajax 调用以验证帐号。问题是该列没有发布到 php.ini 中。
查询功能:
function chkAcct(value,colname){
// var result = null;
$.ajax({
async: false,
url: 'functions.php',
type: 'POST',
data: {action: 'chkAcct'},
// dataType: 'xml',
// contentType: 'application/xml; charset=utf-8',
success: function(response){
if(response){
result = [true,""];
}
else{
result = [false,"This account already exists"];
}
alert(response);
},
});
return result;
}
PHP 功能:
function chkAcct($conn){
$sql = "SELECT dist_id FROM batch WHERE open_flg = '1'";
$query = pg_query($conn,$sql);
$row = pg_fetch_row($query);
$dist = distConversion($row[0]);
$cntrct_id = $dist.$_POST['cntrct_id'];
$sql = "SELECT COUNT(*) FROM addru ad, cntrt ct WHERE ct.cntrct_id = '$cntrct_id' AND ad.cntrct_seq = ct.cntrct_seq AND ad.active_flg = '1'";
$query = pg_query($conn,$sql);
$row = pg_fetch_row($query);
$count1 = $row[0];
$sql = "SELECT COUNT(*) FROM nmaddr nm WHERE nm.cntrct_id = '$cntrct_id'";
$query = pg_query($conn,$sql);
$row = pg_fetch_row($query);
$count2 = $row[0];
$total = $count1+$count2;
if($total === 0){
$myfile = "text.txt";
$fh = fopen($myfile,'a');
fwrite($fh,$total);
fclose($fh);
echo $cntrct_id;
}
}
最后,有问题的行:
{ name:'cntrct_id',
editoptions:{ maxlength:8 },
editrules:{
custom:true,
custom_func: chkAcct,
}
},
我尝试在行的编辑选项中使用 data:{ cntrct_id: 'cntrct_id' } 手动将列的值发送到服务器,但无济于事。我还能尝试什么?