I am trying to call the success call back function inside the jsonGet method and trying to access the variable "size " and "noOfFiles" outside the JsonGet method but it is showing undefined outside the jsonGet method.
I am using the following code
(function()
{
/**
* Alfresco Slingshot aliases
*/
var $html = Alfresco.util.encodeHTML,
$isValueSet = Alfresco.util.isValueSet;
var $html5 = Alfresco.util.encodeHTML,
$isValueSet = Alfresco.util.isValueSet;
if (Alfresco.DocumentList)
{ YAHOO.Bubbling.fire("registerRenderer",
{
propertyName: "FolderInfo",
renderer: function type_renderer(record)
{
var jsNode = record.jsNode;
var nodeRef = jsNode.nodeRef;
var size, noOfFiles;
console.log(size);
console.log(Alfresco.constants.PROXY_URI + "com/acme/nodesize/node-size.json?nodeRef=" + nodeRef);
/*Alfresco.util.Ajax.jsonGet({*/
$.ajax({
url: encodeURI(Alfresco.constants.PROXY_URI + 'com/acme/nodesize/node-size.json?nodeRef='+nodeRef),
async: false,
successCallback:
{
fn: function loadWebscript_successCallback(response, config)
{
var obj = JSON.parse(response.serverResponse.responseText);
if (obj)
{
console.log("AJAX calls works. Printing the folder size " + obj.size + " & no of files " + obj.noOfFiles);
size = obj.size;
noOfFiles = obj.noOfFiles;
alert(size);
console.log("inside success call back function");
}
},
/*scope: this*/
},
/*scope: this*/
});
console.log("Size"+size);
html5 = '<span class="item">' + "Folder Size: " + '<b>' + size + '</b>' + '</span>';
return html5;
}
});
}
})();
but after searching on internet,I learned that jsonGet is asynchronous,so it is exceuted after the synchronous code.so,I replaced the jsonGet method with $.ajax method and set the async to false to make $.ajax synchronous and access the variable outside the jsonGet method.but,still the variables "size" is undefined.
any help would be greatly appreciated.I am trying dis from many days