User Tools

Site Tools


syntax_editor_macros

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
syntax_editor_macros [01/07/2025 13:14] johnsonjohnsyntax_editor_macros [01/07/2025 13:16] (current) johnsonjohn
Line 76: Line 76:
 ====c_GlideAjaxMethod==== ====c_GlideAjaxMethod====
 <code> <code>
 +//text 
 +//GlideAjax, addParam(), getXMLAnswer 
 +  
 +//From client side code, to invoke server side code asynchronously, instantiate a custom GlideAjax object. 
 +//Use the addParam() function, and by convention, the parameter named "sysparm_name" to specify which server side function to invoke. 
 +//Additional arbitrary parameters may also be specified with addParam(); In this example "sysparm_Prefix"
 +//Use getXMLAnswer() to invoke the server-side function and specify a callback function; in this example "finishClientSideWorkONE"
 +//Use a direct parameter in your callback function to make use of data returned by the server; in this case the parameter is named "answerFromServer"
 +function onLoad() { 
 +                g_form.addInfoMessage("BEGIN Client Script"); 
 +  
 +                var ga = new GlideAjax('zJWJ_AjaxFunctions'); //phoenixAjaxUtils is the name of a Server Side Script Include CLASS. 
 +                ga.addParam("sysparm_name", "getMyTitle"); //One parameter must be named sysparm_name.  It tells which function to invoke on the server. 
 +                ga.getXMLAnswer(finishClientSideWork); //Call server function.  When it's complete, then invoke "finishClientSideWork" back here on the client. 
 +  
 +                g_form.addInfoMessage("Additional Code on Client Side 1"); 
 +  
 +                var ga2 = new GlideAjax('zJWJ_AjaxFunctions'); //phoenixAjaxUtils is the name of a Server Side Script Include CLASS. 
 +                ga2.addParam("sysparm_name", "getMyTitleWithPrefix"); //Tells which function to invoke on the server. 
 +                ga2.addParam("sysparm_Prefix", "Sir "); //Additional custom parameter. 
 +                ga2.getXMLAnswer(finishClientSideWorkTWO); //Call server function.  When complete, then invoke "finishClientSideWorkTWO" back here on the client. 
 +  
 +                g_form.addInfoMessage("Additional Code on Client Side 2"); 
 +
 +  
 +function finishClientSideWork(answerFomServer) 
 +
 +                g_form.addInfoMessage("BEGIN finishClientSideWorkONE"); 
 +                g_form.addInfoMessage("Title from Server: " + answerFomServer); 
 +                g_form.addInfoMessage("END finishClientSideWorkONE"); 
 +
 +  
 +function finishClientSideWorkTWO(answerFomServerTWO) 
 +
 +                g_form.addInfoMessage("BEGIN finishClientSideWorkTWO"); 
 +                g_form.addInfoMessage("Title from Server w Prefix: " + answerFomServerTWO); 
 +                g_form.addInfoMessage("END finishClientSideWorkTWO"); 
 +}
 </code> </code>
 ---- ----
syntax_editor_macros.1736284457.txt.gz · Last modified: 01/07/2025 13:14 by johnsonjohn

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki