2

I use such code to catch users clicks:

Event.observe(document, 'click',function(e){
    var x = Event.pointerX(e);
    var y = Event.pointerY(e);
    //exec data storage over ajax
}

The problem is when the user click some link, the next function don't have time to execute entirely and I can't save the click data before redirect to the clicked link.

I saw some jquery implementation, but I don't use jquery.

Community
  • 1
  • 1

1 Answers1

2

If you must execute a function before the redirect you need to override the default action of the link, once your function finishes executing then call the redirect manually.

Im guessing its the ajax that needs to complete before redirecting? If so then you need to add the redirect in the callback function of your ajax.

Jon Taylor
  • 7,865
  • 5
  • 30
  • 55