summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMilian Wolff <milian.wolff@kdab.com>2013-01-21 20:09:11 +0100
committerPierre Rossi <pierre.rossi@gmail.com>2013-11-01 13:57:46 +0100
commite6802ced7665a650de9836cabd9e8753a5cfe859 (patch)
treeb75ab5993e69026e083001350f97ff270db6ee82 /src
parentc31d0515171799026323e9437662d77874a3b3d4 (diff)
downloadqtwebchannel-e6802ced7665a650de9836cabd9e8753a5cfe859.tar.gz
Show error message when webchannel XHR failed and reschedule polling.
This makes it somewhat safer but is still error prone. I think we need a proper WebSocket to make it really reliable. Change-Id: I7a7f6305e026b3d75d906c948233a6bf210ed886 Reviewed-by: Pierre Rossi <pierre.rossi@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/webchannel-iframe.html12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/webchannel-iframe.html b/src/webchannel-iframe.html
index a6addbe..57f63f8 100644
--- a/src/webchannel-iframe.html
+++ b/src/webchannel-iframe.html
@@ -13,8 +13,18 @@
xhr.open("POST", "../" + type, true);
xhr.setRequestHeader("Content-type", "text/json");
xhr.onreadystatechange = function() {
- if (xhr.readyState != 4 || xhr.status != 200)
+ if (xhr.readyState != 4) {
+ // not yet finished loading
return;
+ }
+ if (xhr.status != 200) {
+ console.log("webchannel exec error:", xhr.status, data, type, xhr.responseText);
+ if (type == "POLL") {
+ // reschedule a poll
+ setTimeout(poll, 0);
+ }
+ return;
+ }
// data is fully available now
callback(xhr.responseText);
};