13

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.

3

7 Answers 7

18

AJAX(Asynchronous JavaScript and XML) is:

  • not a programming language, but a new way to use existing standards,
  • simply the act of sending and receiving data asynchronously using JavaScript and XML,
  • often AJAX is used to update parts of a web page without the need to reload the whole page.
Sign up to request clarification or add additional context in comments.

4 Comments

It should be noted that despite its name, AJAX often doesn't involve XML. JSON is used instead quite often.
yes your are right but without xmlhttp you cannot sent the request as my knowledge is concerned , correct me if I am wrong.
With JavaScript you can also update parts of a web page without the need to reload the whole page.
So is AJAX already a part of JS or do we need to include anything in HTML to use it?
7

Javascript is programing lang to complete task on client side in web developement.

Ajax is techonology is not language.

Ajax is combination of javascript(XMLhttpobject) + xml. which allows you to make asynchornous call to server machine and to retrive data to update part of page without sending whole page to server.

Comments

3

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.

1 Comment

Thank you very much for clarifying that AJAX is already a part of JS that deals with server calls.
3

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

1 Comment

Isn't AJAX implemented inside JS by using some functions? If this is so, then AJAX is part of JS right? I am a bit confused...
3

Java script is the client side scripting language while the ajax is the technology which use javascript+xml.when we go to the next page then most of the content remain same,but the whole page is upload, if we use ajax then only the matter that is different from previous page not whole page upload.So by use of ajax we can fast upload the pages.

Comments

2

AJAX uses Javascript to fetch data asynchronously (or synchronously if you REALLY wish).

You will usually use Javascript to fulfill your general scripting needs (moving elements, making on-the-fly calculations, etc.). AJAX is then Javascript making a dynamic HTTP request to fetch data (or invoke an action), which can then process the received data to be displayed on the page.

Comments

2

They're aren't comparable. Javascript is a scripting language which is typically used for client-side functionality although it can exist at server-side (node.js).

AJAX (Asynchronous javascript and XML) is the javascript implementation of partial server requests which is typically carried out using the XMLHttpRequest object. The object itself is accessible from many languages, ajax is the term used for the object's use within the context of javascript.

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.