summaryrefslogtreecommitdiff
path: root/yaksh/static
diff options
context:
space:
mode:
authorprathamesh2017-08-14 14:51:39 +0530
committerprathamesh2017-08-14 14:51:39 +0530
commit49615e5a24ecfdd0b22bae080e7f9bb2507bbfd7 (patch)
treedf6c5d1a56376a92c2c8aa893c4c3b3f2dff52d4 /yaksh/static
parentce995e06e3509a1340061c51dfa08a65c69eef66 (diff)
downloadonline_test-49615e5a24ecfdd0b22bae080e7f9bb2507bbfd7.tar.gz
online_test-49615e5a24ecfdd0b22bae080e7f9bb2507bbfd7.tar.bz2
online_test-49615e5a24ecfdd0b22bae080e7f9bb2507bbfd7.zip
To handle unknown status response from code server
Diffstat (limited to 'yaksh/static')
-rw-r--r--yaksh/static/yaksh/js/requesthandler.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/yaksh/static/yaksh/js/requesthandler.js b/yaksh/static/yaksh/js/requesthandler.js
index 9d023cc..b637928 100644
--- a/yaksh/static/yaksh/js/requesthandler.js
+++ b/yaksh/static/yaksh/js/requesthandler.js
@@ -3,9 +3,15 @@ function submitRequest(){
document.forms["code"].submit();
}
-function check_state(state, uid, success) {
- if (state == "running") {
+function check_state(state, uid) {
+ if (state == "running" || state == "not started") {
setTimeout(get_result(uid), 2000);
+ } else if (state == "unknown") {
+ request_status = "initial";
+ var $notice = document.getElementById("notification");
+ $notice.classList.add("alert");
+ $notice.classList.add("alert-success");
+ $notice.innerHTML = "Your are requesting for a wrong data";
}
}
@@ -24,7 +30,7 @@ function get_result(uid){
} else if(content_type.includes("application/json")) {
res = JSON.parse(data);
request_status = res.status;
- check_state(request_status, uid, res.success);
+ check_state(request_status, uid);
}
}
});
@@ -74,6 +80,7 @@ $(document).ready(function(){
success: function(data, status, xhr) {
content_type = xhr.getResponseHeader("content-type");
if(content_type.includes("text/html")) {
+ request_status = "initial"
document.open();
document.write(data);
document.close();
@@ -81,7 +88,7 @@ $(document).ready(function(){
res = JSON.parse(data);
var uid = res.uid;
request_status = res.state;
- check_state(request_status, uid, false);
+ check_state(request_status, uid);
}
}
});