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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With