DHTMLX Docs & Samples Explorer

Sending Requests with dhtmlxAjax

dhtmlxAjax is static object, which means you do not need to instantiate it each time you need to send AJAX request to server. Also, if you use any dhtmlx component on your page, then you do not need to add any script file to use dhtmlxAjax - it is included in all dhtmlx components. Otherwise you need to add dhtmlxcommon.js file.

Sending GET AJAX Request

To send asynchronous GET request and be able to process a response you need to do the following:


where callbackFunction is a function object which will be called when response from server comes. It gets one argument called loader. This object contains all necessary information about response and some additional capabilities. In details:

  • loader.xmlDoc - HTTP Response object;
  • loader.xmlDoc.responseXML - xml object which came with reponse;
  • loader.xmlDoc.responseText - text which came with response;
  • loader.doXPath(xpathExp, docObj, namespace, result_type) - XPath Processor (see details in related chapter);
  • loader.doSerialization() - returns string representation of XML object got with response;
  • loader.doXSLTransToObject(xslDocument) - makes XSL transformation with object result (see details in related chapter);
  • loader.doXSLTransToString(xslDocument) - makes XSL transformation with string result (see details in related chapter).

To send synchronous GET request you need to do the following:

var loader = dhtmlxAjax.getSync(url);

In case of synchronous request loader object will be returned as a result. It has all features described above.

//async mode
//sync mode
var loader = dhtmlxAjax.getSync(url);

Sending POST AJAX Request

The only difference in making POST request with dhtmlxAjax is additional argument next to URL - POST parameters:

var loader = dhtmlxAjax.postSync(url,params);

where params is a string of name=value pairs united with & like