Atozed Forums
ExecuteJS and CallbackResponse.AddJavaScriptToExecute - Printable Version

+- Atozed Forums (https://www.atozed.com/forums)
+-- Forum: Atozed Software Products (https://www.atozed.com/forums/forum-1.html)
+--- Forum: IntraWeb (https://www.atozed.com/forums/forum-3.html)
+---- Forum: English (https://www.atozed.com/forums/forum-16.html)
+----- Forum: IntraWeb General Discussion (https://www.atozed.com/forums/forum-4.html)
+----- Thread: ExecuteJS and CallbackResponse.AddJavaScriptToExecute (/thread-3786.html)



ExecuteJS and CallbackResponse.AddJavaScriptToExecute - RenSword - 01-15-2024

Is there any difference between ExecuteJS() and CallbackResponse.AddJavaScriptToExecute()?


RE: ExecuteJS and CallbackResponse.AddJavaScriptToExecute - Alexandre Machado - 01-28-2024

ExecuteJS() calls AddJavaScriptToExecuteAsCDATA() internally *when* it is a callback response (async). If the code is being executed from a sync event, it will call AddToInitProc() which also executes the JS code, but when the page loads.

So, in general it is safe to replace CallbackResponse.AddJavaScriptToExecute() by ExecuteJS() (which is waaaay shorter) with the advantage that it will also work during a sync event.


RE: ExecuteJS and CallbackResponse.AddJavaScriptToExecute - RenSword - 01-29-2024

(01-28-2024, 06:02 AM)Alexandre Machado Wrote: ExecuteJS() calls AddJavaScriptToExecuteAsCDATA() internally *when* it is a callback response (async). If the code is being executed from a sync event, it will call AddToInitProc() which also executes the JS code, but when the page loads.

So, in general it is safe to replace CallbackResponse.AddJavaScriptToExecute() by ExecuteJS() (which is waaaay shorter) with the advantage that it will also work during a sync event.

Okay, thanks alex