Check for AJAX request/change within page

Hi all,

In relation to the following thread which I unfortunately didn’t get back to in time before it locked due to other work, I’ve come back to the project and am still facing the same issues.
https://www.sitepoint.com/community/t/efficient-way-to-check-for-changes-within-element/399252/7

I have tried rpg_digital’s solution of using lodash but unfortunately I don’t have sufficient access to load the necessary script as the code is all being served via a third-party application - is there a way to do this without lodash?

As per the other thread, I’m attempting to apply a change to some information on the page which is successfully being applied on load. However, due to user interaction, the information is being reloaded and is therefore undoing my changes.

I’ve been able to identify an element which is changing regularly which I can latch onto but am still unclear as to how to check for this change and reapply my updated information.

Any further help would be much appreciated!

I have to shoot out, but looking back at that I used lo-dash for it’s throttle function.

You can write your own throttle function, they tend to be only a few lines long.

Here is an example with code (Need to scroll down the page to throttleFunc)

1 Like

Hi @Shoxt3r ,

As I was short for time I only gave the Medium link a cursory look. The throttleFunc function in that article needed a few fixes. One to let the callback take arguments, and two a small typo setTimeOut → setTimeout.

I have updated the codepen from before.

Thank you so much for your time looking into this - it looks ideal for my needs! Apologies for my lack of reply - I have been short on time to look into this further recently.

Just one question, if I had to adapt this to watch multiple areas of the page for interaction, how would you recommend that I implement this, or would you say that watching the container for all of these elements would suffice?

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.