0
我正在使用custom_func來驗證編輯中的字段併爲表單編輯添加。這個custom_func正在調用服務器的ajax來驗證帳號。問題是該列沒有被髮送到PHP。將列傳遞給外部ajax調用
jQuery函數:
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,
}
},
我嘗試使用數據:{cntrct_id:「cntrct_id '}在該行的editoptions中手動將該列的值發送到服務器,但無濟於事。我還能嘗試什麼?
mcryan,您的解決方案已解決我的問題。我必須添加該列必須被引用爲$('#cntrct_id')。val(),因爲$('#cntrct_id')打破了網格。只要SO允許,我會盡快接受答案。 – user 2013-02-21 15:17:00
太好了。我已將'.val()'添加到我的答案中。 – mcryan 2013-02-21 15:22:59