How can I get jQuery to perform a synchronous, rather than asynchronous, AJAX request?

Posted by Artem Tikhomirov on Stack Overflow See other posts from Stack Overflow or by Artem Tikhomirov
Published on 2008-09-25T13:26:54Z Indexed on 2010/04/07 13:33 UTC
Read the original article Hit count: 309

Filed under:
|

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.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery