Can I add javascript code that logs every time the user is executing an AJAX call or changing the URL(exiting my page) I want this piece of code to identify the ajax call automatically, I don't want to do it manually wherever there is an ajax call
Asked
Active
Viewed 115 times
0
-
http://www.whathaveyoutried.com - just asking for the code isn't really what this forum is about. Please post something that you've already tried or at least something that shows us that you've thought about it for more than the time it took to write this question. :) – Henrik Andersson Jul 24 '12 at 07:39
-
http://stackoverflow.com/questions/3596583/javascript-detect-an-ajax-event – DuduAlul Jul 24 '12 at 11:49
1 Answers
0
if you are willing to use jQuery than try this one:
create a common function for all ajax requests
function ajxCall(url,data,method)
{
$('#logDiv').html(url+'<br>'); // Placing all request URLs in a debug div
$.ajax({url : url,
method : method ,
data : data , // data will be a jason object or you can set it by changing dataType
dataType:'JSON'})
}
function someEvent() // assign this handler to your event
{
ajaxCall('http::localhost/login.php',
{username:'my_user',password:my_password,
'POST'});
}
You can also create it with out jQuery. I have just described the idea. Hope It helps :) regards.

Rupesh Patel
- 3,015
- 5
- 28
- 49
-
I am looking for something generic that is agnostic to the code that I am using, I am not the on who writes the code, I can just add to it – DuduAlul Jul 24 '12 at 11:44