I just started studying Ajax and I totally have not idea what AJAX is. What is the difference between asynchronous and synchronous request? I would like to seek a very simple example demonstrating their differences.
AJAX short for Asynchronous JavaScript And XML is a programming language. It typically involves sending HTTP requests from client to server and processing the server's response, without reloading the entire page. This process is asynchronous. Comparing to synchronous request which blocks the client until operation completes, asynchronous HTTP is more efficient and user-friendly. Take very simple example, when you are signing up on a commercial website, you can know whether your username is available or not once you finish typing the name. If the username was used already, the website will give you a reminder that your username is used on the same web page. This is the application of AJAX, so you don't need to complete the whole form and click the submit button to know that your username is not available.
AJAX uses two components for request process and display: A browser built-in XMLHttpRequest object (to request data from a web server) JavaScript and HTML DOM (to display or use the data)
It begins with an event occurs in a web page, such as a button is clicked. Then an XMLHttpRequest object is created by JavaScript, followed by sending a request to a web server. Once the web server receives the request, it will process it and send a response back to the web page. Then the webpage utilizes JavaScript to perform update of the web page without reloading the whole page.
AJAX stands for Asynchronous JavaScript And XML
Ajax
main purpose is the loading data
from the server
without refreshing
the web page
It's works in the background thread
without interrupting
UI
thread
AJAX
allows web pages
to be updated asynchronously
by exchanging data
with a web server
behind the scenes. This means that it is possible to update parts of a web page
, without reloading the whole page
.
A browser
built-in XMLHttpRequest
object
which is used to request data from a web server
Example
when you are filling any kind of online form that time observe one thing there is option for country,state,district.
In this country drop down
initially filled with data
but state and district's are empty.
when you select a country like India then Asynchronous
call
goes to server
and fetch the data of state drop down
respective to selected country and so on.
when AJAX
request
fetching the data for the state drop down
you are eligible to work with other parts of the form
.