070-480J Free Dumps Study Materials
Question 16: あなたはWindows Communication
Foundation(WCF)サービスを消費して、Webページを開発しています。このページには
次のコードセグメントを含まれています。 var xhr = new XMLHttpRequest() ;
ページを呼び出して、WCFサービスの要求のステータスの変更をリッスンするxhrHandler(
)メソッドを使用しています。これは、JavaScriptオブジェクトへのWCFサービスからの応
答を変換するxmlToJavaScript()メソッドを使用しています。
xhrHandler()メソッドが自動的に毎回リクエストのステータスの変更を呼び出しなければ
なりません。
あなたはリクエスト・オブジェクトにイベントハンドラを追加する必要があります。どのコ
ード行は使うべきですか。
A. xhr.onCallback = xhrHandler;
B. xhr.onreadystatechange = xhrHandler;
C. xhr.readyState = xhrHandler;
D. xhr.status = xhrHandler;
Correct 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