Global Ajax Events ajaxSend, ajaxSuccess, ajaxError and ajaxComplete do not work
by ranadheemachineni
HTML
<div>
<input id="AjaxTestButton" type="button" name="ajaxtestbutton" value="Start Ajax Test"/>
</div>
<div>
Loaded by ajax request:
<div id="AjaxResponse">
</div>
</div>
JavaScript
$(document).ready(function() {
jQuery('body').ajaxStart(function(){
}).ajaxStop(function(){
}).ajaxSend(function(){
$('.la-ball-spin-fade').show();
}).ajaxComplete(function(){
}).ajaxError(function(){
alert( "ajaxError" );
}).ajaxSuccess(function(){
});
$('#AjaxTestButton').click(function() {
var TestObj = new AjaxTest('');
TestObj.send();
});
});
AjaxTest = function(url) {
this.url = url;
}
AjaxTest.prototype = {
send: function() {
jQuery.ajax({
url: this.url,
timeout: 1000,
beforeSend: function(){ alert("zapme beforeSend"); },
success: function(data){
alert("success");
$('#AjaxResponse').html(data);
},
error: function(){ alert("error"); },
complete: function(){ alert("complete"); },
context: this
});
}
}