4

Does any javascript framework has a function, which:

  • makes AJAX request
  • returns the response

    ( it does not take a callback function as an argument )

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

1
  • 6
    If you're going to do AJAX, you're going to need to learn how to do asynchronous programming. That means passing around callbacks instead of blocking for return values. Commented Feb 11, 2010 at 18:44

3 Answers 3

5

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

Sign up to request clarification or add additional context in comments.

1 Comment

Nice and clear. I like this answer, but I accepted Brian's since he mentioned the framework and the function.
3

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.

2 Comments

@Sky yes, and if you used JSON instead of XML it would be SJAJ... kinda hard to say :)
AJAX is just an invented acronym which seemed to sound good at the time and not some law. XHR (XmlHttpRequest) is more accurate in my view and it doesn't exclude synchronous requests at all.
2

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.

1 Comment

It is synchronous, but it freezes up the browser while the request is loading, has problems with cross-domain, and possibly other issues as well.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.