對象窗口上的設置,如果我在警報下調用函數[ctrUpadateCount],只會得到「固定」,如果我直接調用它不會工作。 任何想法爲什麼?我在另一個項目上遇到同樣的問題。並且必須得到一個解決方案,這是可以應用在這裏的。 我試着解釋下面的代碼... ps:對不起英文不好。Ajax設置全局變量,但超出價值desapear
function ctrUpdateCount(idCtrForm)
{
$.ajaxSetup({ assync: false});
tableName= 'clients';
p_comando="select count(*) total from "+tableName;
$.post("execute.php", {comando : p_comando}, function(json){
v_total=json[1].total ; // <= this retuns 3
window['ctrBuffer_'+idCtrForm].count=v_total;
alert("count inside = "+ window['ctrBuffer_'+idCtrForm].count);//this alerts 3
},'json');
}
jQuery.fn.extend({ ctrLoad: function()
{
if($(this).get(0).tagName =='FORM'){
idCtrForm=$(this).attr('id');
alert("direct count ="+ctrUpdateCount(idCtrForm)); // this will alert 3
// and so the next alert
//teste=ctrUpdateCount(idCtrForm); // but if i use this,
//the next alert will show "undefined"
alert("count after = "+ window['ctrBuffer_'+idCtrForm].count);
}
}
})
哦,你是通過Ajax發送原始SQL嗎?小鮑比桌子會很興奮。 –
好悲痛,這只是一遍又一遍地被問到。 – Pointy