Using the Callback Functions

Top  Previous  Next

Callback functions can be defined with submitProcessForm(), refreshAreas(), refreshBlocks(), refreshOptions(), refreshFields() and  customRefresh() methods calls of MoreMotionAjaxManager function class.

  AjaxMgr.refreshAreas({
    actionName     : 'RefreshDetails'
    ,targetAreas   : 'TA_Details'
    ,requestParams : {ID:this.value}
    ,callbackFunc  : CallMeAfter
    ,userData      : {elm:this}
  });

 

The callback function is called when response is received from the server and response handler completely finishes its work. The parameter passed to the callback function is a MultiPartAjaxResponse object that provides all the information about the request sent and the response received.

  function CallMeAfter(mpar) {
    var response = mpar.getResponse();      // Get the first AjaxResponse object
    var response2 = mpar.getResponse(1);    // Get the second AjaxResponse object
    var request = mpar.getRequest();        // Get the AjaxRequest object that originates this response
    var userData = request.props.userData;  // Get the userData property defined in the request
    userData.elm.style.backgroundColor = "yellow";
  }