AJAX Quiz - MCQ - Multiple Choice Questions
Q. What is AJAX used for?
A. Creating dynamic and interactive web pages by exchanging data with a server without refreshing the entire pageB. Only for form validation in web applications
C. Rendering static HTML content
D. Sending data to a server without expecting a response
Q. Which technology is primarily used for sending AJAX requests and receiving responses?
A. JavaScriptB. HTML
C. CSS
D. XML
Q. Which HTTP method is commonly used for sending data to the server in AJAX requests?
A. GETB. POST
C. PUT
D. PATCH
Q. What is the purpose of the XMLHttpRequest object in AJAX?
A. To send HTTP requests to the server and receive responsesB. To render XML data received from the server
C. To update the HTML content of a web page
D. To validate user input in a form
Q. What is the correct way to create a new XMLHttpRequest object in JavaScript?
A. var xhr = new XMLHttpRequest();B. var xhr = new XMLHttp();
C. var xhr = XMLHttpRequest();
D. var xhr = new Http();
Q. What is the purpose of the open() method in the XMLHttpRequest object?
A. To open a connection to a specific URLB. To send data to the server
C. To receive a response from the server
D. To handle errors in the AJAX request
Q. What is the purpose of the readyState property in the XMLHttpRequest object?
A. To check if the request is ready to be sentB. To determine the current state of the request
C. To handle errors in the AJAX request
D. To check if the response has been received
Q. What is the purpose of the onreadystatechange event handler in AJAX?
A. To handle errors in the AJAX requestB. To update the web page with new data
C. To specify what happens when the readyState changes
D. To send data to the server
Q. What is JSON, and why is it commonly used in AJAX?
A. JSON (JavaScript Object Notation) is a lightweight data-interchange format that is easy to read and write for humans and machines.B. JSON is a programming language used specifically for AJAX data transfer.
C. JSON is a binary format used for efficient data transfer.
D. JSON is a markup language used for structuring data.
Q. How can you handle errors in AJAX requests?
A. By using the onerror event handlerB. By checking the status property of the XMLHttpRequest object
C. By using the try-catch block in JavaScript
D. All of the above