Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between AJAX with JavaScript and jQuery? [closed]

What is the difference between AJAX with jQuery and AJAX with JavaScript?

like image 205
Jay Avatar asked Jun 27 '10 16:06

Jay


People also ask

What is the difference between JavaScript and AJAX?

JavaScript performs client-side operations, while AJAX sends and retrieves information from a server. The use of JavaScript and AJAX together allows code to be executed on the client side machine without the need to send repeated requests for an entire page reload just because a request for data is made to a server.

What is the main difference between JavaScript and jQuery?

1. JavaScript uses JIT[Just in Time Compiler] which is a combination of interpreter and Compile and is written in C. It's a combination of ECMA script and DOM (Document Object Model). While JQuery Uses the resources that are provided by JavaScript to make things easier.

Which is better jQuery or AJAX?

jQuery uses ajax for many of its functions, but it nothing else than a library that provides easier functionality. With jQuery you dont have to think about creating xml objects ect ect, everything is done for you, but with straight up javascript ajax you need to program every single step of the ajax call.

What is the difference between jQuery get () and jQuery AJAX ()?

get() executes an Ajax GET request. The returned data (which can be any data) will be passed to your callback handler. $(selector). load() will execute an Ajax GET request and will set the content of the selected returned data (which should be either text or HTML).


2 Answers

Actually only one of them is a programming language.

  • Javascript is a programming language which is used mainly in webpages for making websites interactive. In this context, when a webpage is parsed by the browser, it creates an in-memory representation of the page. It is a tree structure, which contains all elements on the page. So there is a root element, which contains the head and the body elements, which contain other elements, which contain other elements. So it looks like a tree basically. Now with javascript you can manipulate elements in the page using this tree. You can pick elements by their id (getElementsById), or their tag name (getElementsByTagName), or by simply going through the tree (parentNode, firstChild, lastChild, nextSibling, previousSibling, etc.). Once you have element(s) to work with you can modify them by changing their look, content or position on the page. This interface is also known as the DOM (Document Object Model). So you can do everything with Javascript that another programming language can do, and by using it embedded into wepages you also get an in-memory Object of the current webpage by which you can make changes to the page interactively.

    In recent years JavaScript has also become a popular server-side language running in an environment called Node.js. This opened up a way for you to share common parts of your code between the browser and the server.

  • AJAX is a technique of communication between the browser and the server within a page. Chat is a good example. You can write a message, send a message and recive other messages without leaving the page. You can manage this network interaction with Javascript on the client side, using an XMLHTTP Object provided by the browser.

  • jQuery is a library which aims to simplify client side web development in general (the other two above). It creates a layer of abstracion so you can reuse common languages like CSS and HTML in Javascript. It also includes functions which can be used to communicate with servers very easily (AJAX). It is written in Javascript, and will not do everything for you, only makes common tasks easier. It also hides some of the misconceptions and bugs of browsers.

To sum up:

  • Javascript is a programming language (objects, array, numbers, strings, calculations)
  • AJAX and jQuery uses Javascript
  • jQuery is for simplifing common tasks with AJAX and page manipulation (style, animation, etc.)

Finally, an example just to see some syntax:

// page manipulation in javascript var el = document.getElementById("box"); el.style.backgroundColor = "#000"; var new_el = document.createElement("div"); el.innerHTML = "<p>some content</p>"; el.appendChild(new_el);  // and how you would do it in jQuery $("#box")   .css({ "background-color": "#000" })   .append("<div><p>some content</p></div>"); 
like image 90
25 revs, 4 users 83% Avatar answered Sep 17 '22 09:09

25 revs, 4 users 83%


Javascript, for the purposes of this question, is a client-side (in the browser) scripting language.

jQuery is a library/framework built with Javascript. It is very popular because it (nearly universally) abstracts away cross-browser compatibility issues and it emphasises unobtrusive and callback-driven Javascript programming.

AJAX (Asynchronous Javascript XML) is a method to dynamically update parts of the UI without having to reload the page - to make the experience more similar to a desktop application.

EDIT:

It sounds like you're new to this. I would seriously recommend you check out http://www.w3schools.com/js/default.asp to get started. It's what I used to learn javascript and it's done incredibly well.

like image 40
Tyler Avatar answered Sep 17 '22 09:09

Tyler