我正在使用ajax(通过jquery)与数据库交换数据。由于.ajaxcomplete函数总是基于带有选择器的jquery对象,还有其他方法可以检查这个显式ajax请求是否成功? .ajax不属于像div等任何特定的dom对象。我想在纯Javascript文件中使用Ajax。在这一刻不与特定的html页面关联。 (文档)$ .ajaxComplete()的作品,但不是我想要的jquery ajaxComplete()没有DOM对象
this.replot=function(){
$(this).ajaxComplete(function() {alert('hallo');}); //here is my prob
var that=this;
var anfrage='anfrage= SELECT '+ this.xvaluecol+', '+this.y1valuecol+ ' FROM '+ this.tablename+ ' WHERE '+this.xvaluecol+' <=\'2010-11-06 15:00:00\' AND '+this.xvaluecol+' >=\'2010-11-06 07:00:00\'';
$.ajax({
url : 'getdata.php',
dataType : 'json',
data: anfrage,
type : 'post',
success : function(json) {
if(String(json[0][0]).search('error')==-1)
{
that.data1=json;
that.xaxismin=json[0][0];
that.xaxismax=json[json.length-1][0];
that.yaxsismin=parseInt(that.find_min(json));
that.yaxismax=parseInt(that.find_max(json));
console.log(json);
console.log("yaxismin="+that.yaxismin);
console.log("yaxismax="+that.yaxismax);
//c=new Date((that.xaxismin));
//c.setMinutes(c.getMinutes()+1441+60);
//(c.toLocaleString());
that.update();
$.jqplot(that.divid,[that.data1,that.data2],that.options).replot();
}
else
{
alert('Plot nicht moeglich Fehlercode: '+json[0][1]);
}
}
})
}
它看起来并不像你在这里需要一个全球性的'ajaxComplete'处理程序。您是否尝试在调用'$ .ajax()'时指定'complete'处理程序? – 2012-08-17 09:51:47