Pawel Furmaniak
Pawel Furmaniak

Reputation: 4816

ajax without a callback

Does any javascript framework has a function, which:

I basically want to do the AJAX request the same way I do SQL querys in C, python or whatever.

Upvotes: 4

Views: 8393

Answers (3)

Doug Neiner
Doug Neiner

Reputation: 66211

No, because if it does not take a callback, then it is not Asynchronous, and subsequently it is no longer AJAX (Asynchronous Javascript And XML). And whereas it is common practice to replace the X with JSON or text, the Asynchronous part is pretty important.

You can make a Synchronous request, but it has its own issues... particularly that sometimes the web page and interface appear to freeze until the request returns.

Upvotes: 3

Sky Sanders
Sky Sanders

Reputation: 37104

Yes you can but it is a very bad practice. The javascript engine is single threaded and you risk locking the UI.

Upvotes: 5

Brian Mains
Brian Mains

Reputation: 50728

That would be a synchronous request, and JQuery does have this feature: http://api.jquery.com/jQuery.ajax/ Don't know if it's truly synchronous as I've not tried it that way. Look at the async setting in this documentation, set it to false.

Upvotes: 2

Related Questions