21.) How can you handle both the response and errors in the Fetch API?
A) Using catch() only
B) Using then() only
C) Using then() and catch()
D) Using finally()
22.) What is the responseType property used for in XMLHttpRequest?
A) To define the format of the response
B) To define the status code of the response
C) To define the method used in the request
D) To set the request headers
23.) What is the purpose of the timeout property in XMLHttpRequest?
A) To delay the request
B) To specify the time before the request is automatically aborted
C) To log the request duration
D) To control the server’s response time
24.) Which method is used to open a request in XMLHttpRequest?
A) openRequest()
B) beginRequest()
C) open()
D) start()
25.) Which of the following methods is used to convert a JavaScript object to JSON format?
A) JSON.parse()
B) JSON.stringify()
C) JSON.convert()
D) JSON.toJSON()
26.) What type of data is commonly used in an AJAX response?
A) Plain text
B) JSON
C) XML
D) All of the above
27.) Which of these is an example of an asynchronous task in AJAX?
A) Page reload
B) Form submission
C) Data fetching from a server
D) File download
28.) How do you prevent the default form submission in AJAX?
A) By calling event.preventDefault()
B) By using form.submit()
C) By calling event.stopPropagation()
D) By setting method=”get”
Related