1.11M Members

Detecting new data loaded on page dynamically

 
0
 

Basically what I want to do is to be able to detect when the particular page loads in some data dynamically.

This needs to be general as the script will run across a lot of websites whose js content or other content/configuration I am unaware of. My intention is that everytime something new is loaded onto the page it is picked up within my code so I can execute some other code as a result.

For instance, in an ideal world the following code/similar would exist;

$('body').ajaxRequestMade(function({
    alert('my code here gets executed!');
});

I have not been able to find something like it and need it badly. One particular solution was to simply execute the code every 10 seconds or so (in hope new data may have been loaded in) but this is highly inefficient as it hogs the resources of the browser for about one second or so when my code analyses the page each time. It would be ideal if the analysis was only done at an appropriate point (when new data is loaded in).

Any ideas guys.

 
0
 

Also, the code needs to run successfully on IE, Chrome and Firefox.

 
0
 

I don't know any way of automatically picking up on any AJAX request that happens on a page by dropping in a function. If I thought long and hard I might think of a way. But, why not just add a call to your function in the AJAX request on "complete"?

 
0
 

Please note that the script will be run on a plethora of different websites that are coded by different developers. So the pages this will run on, their content/code will be unknown.

You
This article has been dead for over six months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article