exam questions

Exam 70-480 All Questions

View all questions & answers for the 70-480 exam

Exam 70-480 topic 2 question 1 discussion

Actual exam question from Microsoft's 70-480
Question #: 1
Topic #: 2
[All 70-480 Questions]

You are developing a web page that consumes a Windows Communication Foundation (WCF) service. The page includes the following code segment. var xhr = new XMLHttpRequest() ;
The page uses the xhrHandler() method to listen for changes to the request status of the WCF service calls. It uses the xmlToJavaScript() method to convert the response from the WCF service to a JavaScript object.
The xhrHandler() method must be called automatically each time the request status changes.
You need to add the event handler to the request object.
Which line of code should you use?

  • A. xhr.onCallback = xhrHandler;
  • B. xhr.onreadystatechange = xhrHandler;
  • C. xhr.readyState = xhrHandler;
  • D. xhr.status = xhrHandler;
Show Suggested Answer Hide Answer
Suggested Answer: B 🗳️
/ onreadystatechange: Sets or retrieves the event handler for asynchronous requests.
Specifies a reference to an event handler for an event that fires at every state change readyState
Returns the state of the object as follows:
* 0 = uninitialized open() has not yet been called.
* 1 = open send() has not yet been called.
* 2 = sent send() has been called, headers and status are available.
* 3 = receiving Downloading, responseText holds partial data (although this functionality is not available in IE [3])
* 4 = loaded Done.
/ Example (assuming that there is a function handler():
var oReq = getXMLHttpRequest();
if (oReq != null) {
oReq.open("GET", "http://localhost/test.xml", true);
oReq.onreadystatechange = handler;
oReq.send();
Reference: XMLHttpRequest object; XMLHttpRequest (XHR)
https://msdn.microsoft.com/en-us/library/ie/ms535874(v=vs.85).aspx http://mrfwebdesign.blogspot.ca/2008/11/xmlhttprequest-xhr.html

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
Currently there are no comments in this discussion, be the first to comment!
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...