Home » Microsoft » 70-480 v.2 » How should you complete the relevant code?
HOTSPOT
A company has an XML file named products.xml on a web server. The file contains a list of the products that the company sells.
You need to display the contents of the products.xml file in a DIV element named Output.
How should you complete the relevant code? (To answer, select the appropriate option from each drop-down list in the answer area.)
Hot Area:
Correct Answer:
Explanation/Reference:
Explanation:
When readyState is 4 and status is 200, the response is ready:
Example xmlhttp.onreadystatechange=function()
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById(“myDiv”).innerHTML=xmlhttp.responseText;
} }
Note:
readyState == 4
Holds the status of the XMLHttpRequest. Changes from 0 to 4:
0: request not initialized
1: server connection established
2: request received
3: processing request
4: request finished and response is ready status==200
200: "OK"
404: Page not found
Reference: AJAX – The onreadystatechange Event