Hello. I have a javascript widget witch provides standard extension points. One of them is the beforecreate function. It should return false to prevent an item from being created.
I've added an AJAX call into this function using jQuery:
beforecreate: function(node,targetNode,type,to) {
jQuery.get('http://example.com/catalog/create/' + targetNode.id + '?name=' + encode(to.inp[0].value),
function(result) {
if(result.isOk == false)
alert(result.message);
});
}
But I want to prevent my widget from creating the item, so I should return false in the mother-function, not in the callback. Is there any way to perform a synchronized AJAX request using jQuery or any other API? Thanks.