Role-specific XMLHttpRequest Interview Questions & Answers:
1. Explain getAllResponseHeaders ()?
getAllResponseHeaders ():- Returns a collection of HTTP headers as string. If you want a specific header value, you can use getResponseHeader ("header name")
2. Explain Onreadystatechange?
Onreadystatechange: - This is a event handler, which fires at every state change.
Response: - Returns the response as XML. Therefore, this gives us DOM object model, which can then be traversed.
4. What is SetRequestHeader ("label"," value")?
SetRequestHeader ("label"," value"):- Sets label value pair for a HTTP header.
Response Text: - Returns the response in plain string.
6. How do we do asynchronous processing using Ajax?
xmlHttpObj.onreadystatechange = function1();
Above is the code snippet, which will help us to do asynchronous processing. So function1 () will be called when the XMLHTTP request object goes to on ready state change.
The send(content) method transmits the request, optionally with postable string or the data of DOM object.
8. What is open(arg, arg,arg,arg,arg) function?
The open("method", "URL"[, asyncFlag[, "userName"[, "password"]]]) is used to assign the destination URL, method, and other optional attributes of a request.
9. What is getResponseHeader("headerLabel")?
The getResponseHeader("headerLabel") method is used to return the string value of a single header label.
The abort() is used to stop the current request.
https://InterviewQuestionsAnswers.ORG.