Browser plugins and Ajax requests


John Clarke
I know this isn't really an App Builder issue but is there anyway that I can add code to the WebExtContent event to detect when all Ajax related activity on the content page has been completed ? I would really appreciate all advice offered regarding this.

DecSoft

Hello John,

If we are talking about our own Ajax calls (for example, using jQuery), then yes... may we can do something about... however, if we are talking of the Ajax calls made by the content page... I think there is not a way to know that, John, at least in my knowledge. If you refer here what you are trying to do, maybe we can find a possible workaround, for example, maybe can be stupid, but, these days a page can't take too much time in order to be loaded, so, if we wait a few seconds (five, more?) may we can **asume** that all the things are already loaded...



John Clarke
I am talking about Ajax calls made on the contents page. Basically as the user clicks on items on the page the plugin takes certain actions. However, the developers have started to add Ajax calls to add other items. So it would be good to get the plugin to wait for the Ajax calls to complete before attempting to reattach events to the objects on the page.

DecSoft

Hello John,

I think there is no way to know when all the AJAX calls in the content page has been done: we can't control something like that. However, maybe we can use event delegation. I will talk about the jQuery event delegation: as a task for you, may you can find some possible vanilla JS to be used, so you no need to add the jQuery library as a content script.

If you add the jQuery library as a content script, you can write some code like the below in another content script or the WebExtContent app's event:

The above jQuery / Javascript code attach a click event handler to all the paragraphs in the body, but, not only the existing ones: also the possible paragraphs added later into the body.



John Clarke
Is there anyway to detect changes within either the HTML tag, the body tag or the document object?

DecSoft

Hello John,

I never deal with something like that, but, may you can take a look at the MutationObserver interface.



John Clarke
I had a look at that. In the end I created a timer function that refreshed every quarter of a second. Its not elegant but it seems to work.

DecSoft

Hello John,

If you can do the job, maybe it's enough. Maybe you can study a bit more the event delegation (explained above) or the Mutation interface (explained above)... just in case you can get it working without the timer usage.


Todo el mundo puede leer el foro de soporte de DecSoft para aprender del mismo, sin embargo, sólo los clientes de DecSoft pueden abrir nuevos hilos. Compre una o más licencias de productos de DecSoft y obtendrá este y otros beneficios.

Este sitio utiliza "cookies" útiles para almacenar sus preferencias.

Bien. Ocultar esta nota. Obtener más información.