Skip to content

Instantly share code, notes, and snippets.

@natecavanaugh
Created March 22, 2013 16:36
Show Gist options
  • Save natecavanaugh/5222770 to your computer and use it in GitHub Desktop.
Save natecavanaugh/5222770 to your computer and use it in GitHub Desktop.
A version of Liferay JS services that return synchronously (not recommended)
function getServiceSync() {
var xhr = null;
var args = parent.Liferay.Service.parseInvokeArgs(arguments);
var syncIOConfig = {
sync: true,
on: {
success: function(event, id, obj){
xhr = obj;
}
}
};
args[1] = parent.AUI().merge(args[1], syncIOConfig);
parent.Liferay.Service.invoke.apply(Liferay.Service, args);
if(xhr){
return eval('(' + xhr.responseText + ')');
}
};
getServiceSync(
'/mbcategory/get-categories',
{
groupId: themeDisplay.getScopeGroupId(),
parentCategoryId: 0,
status: 0,
start: -1,
end: -1
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment