Reputation: 6663
I have a single page application where all the subpages are loaded using jQuery.load() or .Ajax() functions.
I have set up ajaxStart() and ajaxStop to display an animation while performing the request and it is working fine. The code I use is the following:
$(document).ajaxStart(function (){
//$('.contenitore').toggle('fast');
$('#darkLayer').show();
document.title = 'sto elaborando...';
resizeDiv();
}).ajaxStop(function (){
//$('.contenitore').toggle('fast');
$('#darkLayer').hide();
document.title = 'J.E.N.I.U.S.';
resizeDiv();
});
I'd like to be able to create a log of what the user does and so I'd like to store in a mysql log what the user has done. Does anyone know how to pass to ajaxStart and ajaxStop the url passed to the .load() or .ajax() function? This way I will have a single point where to use the function that will log the data (user, when, what).
Upvotes: 0
Views: 154
Reputation: 19372
Taken from here: http://api.jquery.com/ajaxcomplete/
$.ajaxComplete(function(event, xhr, settings) {
console.log(settings.url);
});
or You can define beforeSend handler globally:
$.ajaxSetup({
beforeSend: function(xhr, settings) {
console.log(settings.url);
}
});
Upvotes: 1