Bug 16541 - Update examples to use async XHR
authorAdrian Bateman <adrianba@microsoft.com>
Fri, 03 May 2013 08:44:26 -0700
changeset 109 f00bca89a115
parent 108 b60bf8077d9c
child 110 29422cdbc179
Bug 16541 - Update examples to use async XHR
encrypted-media/encrypted-media.html
encrypted-media/encrypted-media.xml
--- a/encrypted-media/encrypted-media.html	Thu May 02 12:35:13 2013 -0700
+++ b/encrypted-media/encrypted-media.html	Fri May 03 08:44:26 2013 -0700
@@ -1055,10 +1055,14 @@
     var message = event.<a href="#dom-message">message</a>;
 
     var xmlhttp = new XMLHttpRequest();
-    xmlhttp.open("POST", "http://.../getkey", false);
+    xmlhttp.open("POST", "http://.../getkey");
+    xmlhttp.onreadystatechange = function() {
+      if(xmlhttp.readyState==4) {
+        var key = new Uint8Array(xmlhttp.response);
+        keySession.<a href="#dom-update">update</a>(key);
+      }
+    }
     xmlhttp.send(message);
-    var key = new Uint8Array(xmlhttp.response);
-    keySession.<a href="#dom-update">update</a>(key);
   }
 &lt;/script&gt;
 
@@ -1094,10 +1098,14 @@
       throw "Could not create license request";
 
     var xmlhttp = new XMLHttpRequest();
-    xmlhttp.open("POST", "http://.../getkey", false);
+    xmlhttp.open("POST", "http://.../getkey");
+    xmlhttp.onreadystatechange = function() {
+      if(xmlhttp.readyState==4) {
+        var license = new Uint8Array(xmlhttp.response);
+        keySession.<a href="#dom-update">update</a>(license);
+      }
+    }
     xmlhttp.send(request);
-    var license = new Uint8Array(xmlhttp.response);
-    keySession.<a href="#dom-update">update</a>(license);
   }
 &lt;/script&gt;
 
@@ -1155,10 +1163,14 @@
       throw "Could not create license request";
 
     var xmlhttp = new XMLHttpRequest();
-    xmlhttp.open("POST", licenseUrl, false);
+    xmlhttp.open("POST", licenseUrl);
+    xmlhttp.onreadystatechange = function() {
+      if(xmlhttp.readyState==4) {
+        var license = new Uint8Array(xmlhttp.response);
+        keySession.<a href="#dom-update">update</a>(license);
+      }
+    }
     xmlhttp.send(request);
-    var license = new Uint8Array(xmlhttp.response);
-    keySession.<a href="#dom-update">update</a>(license);
   }
 &lt;/script&gt;
 
@@ -1184,7 +1196,7 @@
     xmlhttp = new XMLHttpRequest();
     xmlhttp.keySession = keySession;
     xmlhttp.onreadystatechange = handleMessageResponse;
-    xmlhttp.open("POST", licenseUrl, true);
+    xmlhttp.open("POST", licenseUrl);
     xmlhttp.send(message);
   }
 
--- a/encrypted-media/encrypted-media.xml	Thu May 02 12:35:13 2013 -0700
+++ b/encrypted-media/encrypted-media.xml	Fri May 03 08:44:26 2013 -0700
@@ -1005,10 +1005,14 @@
     var message = event.<precoderef>message</precoderef>;
 
     var xmlhttp = new XMLHttpRequest();
-    xmlhttp.open("POST", "http://.../getkey", false);
+    xmlhttp.open("POST", "http://.../getkey");
+    xmlhttp.onreadystatechange = function() {
+      if(xmlhttp.readyState==4) {
+        var key = new Uint8Array(xmlhttp.response);
+        keySession.<premethodref>update</premethodref>(key);
+      }
+    }
     xmlhttp.send(message);
-    var key = new Uint8Array(xmlhttp.response);
-    keySession.<premethodref>update</premethodref>(key);
   }
 &lt;/script&gt;
 
@@ -1044,10 +1048,14 @@
       throw "Could not create license request";
 
     var xmlhttp = new XMLHttpRequest();
-    xmlhttp.open("POST", "http://.../getkey", false);
+    xmlhttp.open("POST", "http://.../getkey");
+    xmlhttp.onreadystatechange = function() {
+      if(xmlhttp.readyState==4) {
+        var license = new Uint8Array(xmlhttp.response);
+        keySession.<premethodref>update</premethodref>(license);
+      }
+    }
     xmlhttp.send(request);
-    var license = new Uint8Array(xmlhttp.response);
-    keySession.<premethodref>update</premethodref>(license);
   }
 &lt;/script&gt;
 
@@ -1105,10 +1113,14 @@
       throw "Could not create license request";
 
     var xmlhttp = new XMLHttpRequest();
-    xmlhttp.open("POST", licenseUrl, false);
+    xmlhttp.open("POST", licenseUrl);
+    xmlhttp.onreadystatechange = function() {
+      if(xmlhttp.readyState==4) {
+        var license = new Uint8Array(xmlhttp.response);
+        keySession.<premethodref>update</premethodref>(license);
+      }
+    }
     xmlhttp.send(request);
-    var license = new Uint8Array(xmlhttp.response);
-    keySession.<premethodref>update</premethodref>(license);
   }
 &lt;/script&gt;
 
@@ -1134,7 +1146,7 @@
     xmlhttp = new XMLHttpRequest();
     xmlhttp.keySession = keySession;
     xmlhttp.onreadystatechange = handleMessageResponse;
-    xmlhttp.open("POST", licenseUrl, true);
+    xmlhttp.open("POST", licenseUrl);
     xmlhttp.send(message);
   }