I am working on a project in which I use a lot of ajax calls to make the site interaction more elegant. The process I used is a link to a script that performs the corresponding action stored as href in the link tag. Then I use jquery to target this element and disable the default action and make an ajax call.
The problem is that the $(document).ready() function does not execute properly or is delayed during execution before the user can click the links. This causes the page to open through normal browser loading.
I have implemented code that determines whether the code is executed through ajax or through a browser, so all that happens is loading a blank page. In some cases, I can determine the type of execution and respond differently, but in other cases, if it is not executed by ajax, this causes problems.
Is there a way to make sure that the default action for links is disabled at any time, regardless of the page loading progress, or is there a better approach than the one I take?
source share