Commit a840e3a8 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

use sendjsonrequest in collapsabletree

parent 7e80d6e2
......@@ -45,17 +45,11 @@ function CollapsableTree(data, source) {
}
});
var req = getXMLHttpRequest();
req.open('post', self.source);
req.setRequestHeader('Content-type','application/x-www-form-urlencoded');
var d = sendXMLHttpRequest(req,queryString(request_args));
d.addCallbacks(function (response) {
var data = evalJSONRequest(response);
sendjsonrequest(self.source, request_args, 'POST', function (data) {
if (!data.error) {
if (data.message) {
if (data.data) {
// Add the new children into the list item that was expanded
var ul = self.convertDataToDOM(data.message);
var ul = self.convertDataToDOM(data.data);
appendChildNodes(p, ul);
p.child = ul;
}
......@@ -67,15 +61,6 @@ function CollapsableTree(data, source) {
// Replace the 'expand' link with a 'collapse' one
replaceChildNodes(p.id + '_toggle', self.getCollapseLink(p));
}
else {
alert('did not get data :(');
// @todo insert sad face or something
}
processingStop();
}, function () {
alert('no data for you!');
processingStop();
});
}
else {
......
......@@ -55,7 +55,9 @@ $data = get_records_sql_array("SELECT id, artefacttype, container, title
AND owner = ?
ORDER BY title", array($pluginname, $userid));
if (!$data) {
json_reply(false, null);
echo json_encode(array('error' => false,
'data' => false));
exit;
}
// Format the data for return. Each artefact type has the opportunity to format
......@@ -102,6 +104,7 @@ foreach ($artefacts as $artefact) {
'rendersto' => call_static_method($artefactclass, 'get_render_list')
);
}
json_reply(false, $items);
echo json_encode(array('error' => false,
'data' => $items));
?>
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment