How to check if a specific id is called from jQuery?

I have a MainContent div that contains the main content of a website that can be downloaded from ajax.

how can I find out if $("#MainContent").load("someUrl") , so that I can push the new history state to a web browser?

+6
source share
1 answer

As LSletty said, if you want to know when it is called, use the handler from .load () itself:

 $("#MainContent").load("path/content.html", function(){ // Do stuff when load is called ... }); 

More info here: jQuery download event

To complete the action after completion, I would use the .done () handler.

Use it as follows:

 $("#MainContent").load("path/content.html").done(function(){ // Do stuff when load is done ... }); 

From jQuery docs:

Add handlers that will be called when the Deferred object is enabled.

More info here: deferred.done () jQuery

+1
source

Source: https://habr.com/ru/post/985405/


All Articles