Send information about clicked link to the server before redirect

前端 未结 5 863
感动是毒
感动是毒 2020-12-21 05:20

We\'re creating a click tracking app, that builds heatmaps. I\'m writing a script which users are suppose to insert into their pages for tracking to work.

It works

5条回答
  •  臣服心动
    2020-12-21 05:43

    So if I understand right, you want your ajax logs completed before the page unloads and follows a link href. This sounds like a perfect case where you could consider using Deferreds in jQuery.

    When your user clicks on anything that's supposed to take him away from the page, just check your promise status. If it's not resolved, you could throw a modal window over the page, and ask the user to wait til the progress is complete. Then, add a new pipe to your deferred, telling it to change the location href once everything is complete.

    Let me know if this is the scenario. If it is, I'll explain in more detail. No use continuing if I didn't understand your requirement properly

提交回复
热议问题