1

I learning about the use of AJAX in web development, and I need to know if AJAX always require the use of node.js, or JQUERY?

Thanks.

1
  • 2
    Ajax only requires Javascript. Node.js is a server side technology and jQuery is a Javascript framework. Commented Nov 28, 2015 at 21:56

3 Answers 3

1

That is a very broad question, so the answer might be broad as well:

The short answer: Ajax does not require jQuery nor Node.js.

In practice, Ajax is a technology for asynchronous operations utilized by Javascript send data to and retrieve from a server asynchronously(1). Ajax is fully available in plain, vanilla Javascript, and it works as follows (example taken from Wikipedia, see sources):

// This is the client-side script.
// Initialize the Http request.
var xhr = new XMLHttpRequest();
xhr.open('get', 'send-ajax-data.php');
// Track the state changes of the request.
xhr.onreadystatechange = function() {
    var DONE = 4; // readyState 4 means the request is done.
    var OK = 200; // status 200 is a successful return.
    if (xhr.readyState === DONE) {
        if (xhr.status === OK) {
            alert(xhr.responseText); // 'This is the returned text.'
        } else {
            alert('Error: ' + xhr.status); // An error occurred during the request.
        }
    }
};
// Send the request to send-ajax-data.php
xhr.send(null);

This is a classic example, showing both how to use Ajax with vanilla Javascript, and also why it's much easier with other means such as jQuery, shortening the same snippet to just:

$.ajax({
    url: "http://fiddle.jshell.net/favicon.png",
}).done(function(data) {
    // Do something with data.
});

Sources (including vanilla Ajax examples):

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

Comments

1

There is no need to use node.js to perform an Ajax request. You can make an Ajax request even using vanilla Javascript. However, jQuery made the Ajax request is very easy and cross-browser compatible with just some lines of code. So, I recommend you to stick with jQuery instead of using vanilla Javascript.

You can find more information regarding the jQuery Ajax feature here: http://api.jquery.com/jquery.ajax/

You can also find more information about the vanilla Javascript Ajax request feature here: http://www.w3schools.com/ajax/

Comments

0

No, most browsers supply means to perform asynchronous javascript requests but libraries such as jQuery partly came about to smooth over the differences between browsers, making ajax a lot more portable.

Modern browsers generally don't have so great differences, so portability is probably is less of an issue, but using libraries has become common practice.

Comments

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.