Skip to content

Commit

Permalink
Richer msgs for xhr states displaying
Browse files Browse the repository at this point in the history
  • Loading branch information
Marssssssss committed Oct 10, 2019
1 parent 4594218 commit 8579456
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion assets/cases/05_scripting/11_network/NetworkCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,7 @@ cc.Class({

var msg = this.tag + " disconnected!";
this.socketIO.textKey = i18n.t("cases/05_scripting/11_network/NetworkCtrl.js.12") + msg;
this.socketIOResp.string = msg;
},

reconnecting: function () {
Expand Down Expand Up @@ -257,7 +258,12 @@ cc.Class({
xhr["on" + eventname] = function () {
eventLabel.string = eventLabelOrigin + "\nEvent : " + eventname;
if (eventname === 'timeout') {
label.string = '(timeout)';
label.string += '(timeout)';
}
else if (eventname === 'loadend') {
if (eventname !== '(timeout)') {
label.string += '...loadend!';
}
}
};
});
Expand All @@ -267,6 +273,21 @@ cc.Class({
if (xhr.readyState === 4 && xhr.status >= 200) {
label.string = handler(xhr.responseText);
}
else if (xhr.status === 404) {
label.string = "404 page not found!"
}
else if (xhr.readyState === 3) {
label.string = "Request dealing!";
}
else if (xhr.readyState === 2) {
label.string = "Request received!";
}
else if (xhr.readyState === 1) {
label.string = "Server connection established! Request hasn't been received";
}
else if (xhr.readyState === 0) {
label.string = "Request hasn't been initiated!";
}
};
},

Expand Down

0 comments on commit 8579456

Please sign in to comment.