Calling a Script Include Client-side

  • Use the GlideAjax Class - Enables Client Script and UI Policies to call server-side code in Script Includes - Pass paremeters to Script Includes - Use the returned data from the server

  • Create a new GlideAjax object for the Script Include of interest

  • Pass parameters to the Script Include - All parameters begin with sysparm_ - Reserved parameters sysparm_name identifies the method
  • Make an asynchronous call to the server
  • Callback function processes returned data
var gaDesc = new GlideAjax('HelloWorld');
gaDesc.addParam('sysparm_name', 'alertGreeting');
gaDesc.addParam('sysparm_user_name', 'Ruth');
gaDesc.getXML('HelloWorldParse');

function HelloWorldParse(response) {
var answerFromXML = response.responseXML.
documentElement.getAttribute("answer");
alert(answerFromXML);
}

The code shown here would be wrapped in a function ( onLoad, onSubmit, onChange ) depending on the type of Client Script.

In this example the GlideAjax object is used to call the Script Include and pass in parameters. The reserved parameter sysparm_name tells GlideAjax which function in the Script Include to use. All passed in parameters must start with sysparm_.

results matching ""

    No results matching ""