0

I know that AJAX makes the page more interactive and real time, but do I need jQuery if I would be using AJAX?

4
  • 6
    You don't need jQuery, but jQuery makes it easier. You can use XMLHttpRequests directly. See the MDN reference Commented Nov 26, 2014 at 1:52
  • Hardly any easier, unless you take all the IE6 fallbacks into account. If you go for modern browser support (IE8 or IE9 and above), you can just use XMLHttpRequest and you won't need browser-specific exceptions. Commented Nov 26, 2014 at 2:09
  • Given the context of your question, you might want to read: youmightnotneedjquery.com It shows native Javascript solutions for common problems that are (too?) often solved using jQuery. Commented Nov 26, 2014 at 2:12
  • jQuery is written in javascript. Therefore, anything jQuery can do can be done directly in javascript. Commented Nov 26, 2014 at 2:19

1 Answer 1

1

You don't need to jQuery in order to use AJAX. JavaScript has its own way.

Like this:

Initialization

var xmlhttp;
if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari
    xmlhttp = new XMLHttpRequest();
} else { // code for IE6, IE5
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}

Request Sending

xmlhttp.open("GET","demo_get.asp",true);
xmlhttp.send();

You can learn more here about javascript ajax here

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

1 Comment

I think by now we can skip the whole IE6- stuff and show how simple Ajax can actually be, even without jQuery.

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.