Hi,
I have been trying to update to 4.1 but am having real issues with the new Ajax api, I used to use
dhtmlxAjax.post(‘?’,‘action=getsomething’,function (loader) {
var result = loader.doXPath(“/items/item[@id=‘success’]”,null,null,‘single’);
var success = result.firstChild.nodeValue;
if(success == ‘Yes’) {
dosomething ();
}
});
Trying to migrate with new API I am using below, I have added a few alerts to show whats happening
window.dhx4.ajax.post(“?”, “action=getsomething”, function(loader) {
var text = loader.xmlDoc.responseText;
alert(text);
var xml = loader.xmlDoc.responseXML;
alert(JSON.stringify(xml));
var items = [];
var nodes = xml.getElementsByTagName(“items”);
for (var q=0; q<nodes.length; q++) {
items.push({
name: nodes[q].getAttribute(“name”),
value: nodes[q].getAttribute(“value”)
});
}
alert(JSON.stringify(items));
});
the results of the alerts are
responseText
which looks fine and header set correctly to text/xml
responseXML
{“location”:null}
Which doesn’t look right
items
[{“name”:null,“value”:null}]
Which would be correct given the xml object …
This will be a real hindrance in migration as I have many uses of dhtmlAjax and doXpath in many applications.
I am using Pro release 4.1.2
Any help appreciated.
Thanks,
Dave