Which code segment or segments should you use?

Posted by: Pdfprep Category: 70-480 Tags: , ,

DRAG DROP

You are creating a function named getText().

The function must retrieve information from text files that are stored on a web server.

You need to develop the function to meet the requirement.

Which code segment or segments should you use? (To answer, drag the appropriate command from the list of commands to the correct location or locations in the work area. Each code segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.)

Answer:

Explanation:

* onreadystatechange

When a request to a server is sent, we want to perform some actions based on the response.

The onreadystatechange event is triggered every time the readyState changes.

The readyState property holds the status of the XMLHttpRequest.

Example

xmlhttp.onreadystatechange=function ()

{

if (xmlhttp.readyState==4 && xmlhttp.status==200)

{

document.getElementById("myDiv").innerHTML=xmlhttp.responseText;

}

}

* Send a Request To a Server

To send a request to a server, we use the open() and send() methods of the XMLHttpRequest object:

xmlhttp.open("GET","xmlhttp_info.txt",true);

xmlhttp.send();

Reference: AJAX – The onreadystatechange Event; The XMLHttpRequest Object

Leave a Reply

Your email address will not be published.