performs a sync-GET ajax request
url | string | url to the server side |
object | loader object |
// simple data sending
var r = dhx.ajax.getSync("server.php?keep_alive=1");
to prevent caching in some browsers an extra param like "dhxr0123456789" will be added
(to disable: dhx.ajax.cache=true, please check details here)
sync GET request will be performed
var r = dhx.ajax.getSync("server.php");
console.log(r.xmlDoc.responseText); // script will wait for response
// for php
header("Content-Type: text/xml");
<!-- assuming that the response is the following -->
<items>
<item name="first" value="a"/>
<item name="second" value="b"/>
</items>
var r = dhx.ajax.getSync("server.php");
var items = [];
var xml = r.xmlDoc.responseXML;
var nodes = xml.getElementsByTagName("items");
for (var q=0; q<nodes.length; q++) {
items.push({
name: nodes[q].children[0].getAttribute("name"),
value: nodes[q].children[0].getAttribute("value")
});
}
// assuming that the response is the following
{status: "ok", data: "value", data2: "value2"}
var r = dhx.ajax.getSync("server.php");
var t = dhx.s2j(r.xmlDoc.responseText); // convert response to json object
if (t != null && t.status == "ok") {
// response is ok
}
added in 4.0
Back to top