Which code segment or segments should you use?

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.)

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:



Leave a Reply 4

Your email address will not be published. Required fields are marked *


bossov

bossov

ok, maybe it’s my bad, but I think there is something wrong with parenthesis…

Will

Will

The code is missing a closing angle bracket between line 138 and 139. So this question has a bug in it.

Will

Will

Oops, I meant the code is missing a closing curly brace, }, between line 138 and 139.

brkyctn

brkyctn

Explanation/Reference:
* 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