Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between ajax and javascript

Can anyone tell me where one should use javascript and where one should use ajax? Also, what is the main difference between them?

I have searched on the web and got an idea that ajax should be use when we want to send some data or request to the server in background...

Other than that I don't have any clear answer for my questions.

like image 580
Priyanka Avatar asked Feb 13 '12 07:02

Priyanka


2 Answers

AJAX ⊂ JavaScript.

AJAX is a part of JavaScript that deals with transferring data to and from the server without requiring a full page reload, basically.

So you should use AJAX whenever the server needs to do something. This can be when the user starts typing something, to provide on-the-fly autocomplete options. Or when submitting a form to get a "smoother" loading effect than a pageload.

However there are times when you shouldn't use AJAX. You shouldn't use it as a substitute for actually loading a different page. Facebook and other sites of similar size use this method, and it's very bad practice in my opinion, as it makes it unnecessarily complicated.

like image 93
Niet the Dark Absol Avatar answered Sep 18 '22 16:09

Niet the Dark Absol


Javascript is a programming Language - a client side scripting language

AJAX is a technology that uses JavaScript and XML such that requests can be made and data retrieved from the server asynchronously in the background without interfering with the display and behaviour of the existing page.

You might need to learn JavaScript before extending to AJAX

like image 25
david Avatar answered Sep 21 '22 16:09

david