Harpal Singh Pa
Tera Contributor

Glide Ajax

AJAX (Asynchronous JavaScript and XML)

AJAX: Enables web applications to send and retrieve information to and from server in the background without impacting the user experience with the displayed web page.

GlideAjax: The GlideAjax Class allows the execution of server side code form the client. Glide Ajax pass parameters to the script include and using naming conventions, allows the use of these parameters.

There are two parts of GlideAjax script: client-side and server-side code.

Using GlideAjax in client script:

  1. Create a GlideAjax instance by calling the GlideAjax Constructor. As the argument to the constructor, specify the name of the Script include that contains the method you want to call.
    ex: var gr = new GlideAjax(“Script Include”);
  2. Call the addParam method with the sysparm_name parameter and the name of the script include method.
    ex: ga.addParam(‘sysparm_name’,”name of method”);
  3. (Optional) We can call addParam method one or more time to provide the script include code with other parameters it needs.
  4. Code it then executed with the getXML() or getXMLWait() function.

Important Notes:

  • Client Side Code: -
    1. addParam: addParam(String parm_name, String param_value);
      Specify a parameter name and value to be passed to the server-side function associated with this GlideAjax object.
    2. Note: - The first call to addParam should be with the parameters "sysparm_name" and the name of the server-side method you want to call.
    3. Don’t use the predefined names for own parameters
      1. sysparm_name
      2. sysparm_function
      3. sysparm_value
      4. sysparm_type
    4. getXML:- This is preferred method for executing the code, because it is asynchronous and does not hold up the execution of other client.
    5. getXMLWait :- This is not available to scoped application. This is not a recommended but it is available. This can ensure the execution, but can cause the application to seem unresponsive, significantly degrading the user experience of any application that uses it.

 

  • Server Side Code :-
    1. Script Include: - When creating the script include, you must set the name field to be exactly the same as the class name.
    2. Function names starting with the “_” are considered as private and are not client callable from Client.
    3. Avoid Overriding methods of ”AbstractAjaxProcessor”, including initialize. While it is possible to invoke methods of your superclass object which you have overridden, it is complicated and best avoided together.

 Links: Glide Ajax

 

 

Version history
Last update:
‎12-19-2018 11:19 AM
Updated by: