Setup ajax timeout to 2 minutes to allow long running queries

This commit is contained in:
Dan Sosedoff
2016-01-21 20:13:12 -06:00
parent d53c94eb91
commit 5e47e8bd29
2 changed files with 10 additions and 3 deletions

File diff suppressed because one or more lines are too long

View File

@@ -59,7 +59,10 @@ function getPagesCount(rowsCount) {
} }
function apiCall(method, path, params, cb) { function apiCall(method, path, params, cb) {
var timeout = 120000; // 2 mins is enough
$.ajax({ $.ajax({
timeout: timeout,
url: "/api" + path, url: "/api" + path,
method: method, method: method,
cache: false, cache: false,
@@ -71,6 +74,10 @@ function apiCall(method, path, params, cb) {
cb(data); cb(data);
}, },
error: function(xhr, status, data) { error: function(xhr, status, data) {
if (status == "timeout") {
return cb({ error: "Query timeout after " + (timeout / 1000) + "s" });
}
cb(jQuery.parseJSON(xhr.responseText)); cb(jQuery.parseJSON(xhr.responseText));
} }
}); });