diff --git a/dist/app.js b/dist/app.js index e99fa312..603ba5e6 100644 --- a/dist/app.js +++ b/dist/app.js @@ -1241,10 +1241,20 @@ return $.ajax( $.extend({ url: this.base_uri + params.path, dataType: "json", + contentType: "application/json", error: function(xhr, type, message) { + //we had an error, it could be that we're talking to an old version of elasticsearch that doesn't support cross origin requests with a contentType set, so try again without it. if("console" in window) { - console.log({ "XHR Error": type, "message": message }); + console.log({ "XHR Error": type, "message": message, "retrying": true }); } + var repeatRequestParams = this; + delete repeatRequestParams['contentType']; + repeatRequestParams['error'] = function(xhr, type, message) { + if("console" in window) { + console.log({ "XHR Error": type, "message": message, "retrying": false }); + } + } + $.ajax(repeatRequestParams); } }, params) ); }, diff --git a/src/app/services/cluster.js b/src/app/services/cluster.js index 1133cf60..4a3e4612 100644 --- a/src/app/services/cluster.js +++ b/src/app/services/cluster.js @@ -14,10 +14,20 @@ return $.ajax( $.extend({ url: this.base_uri + params.path, dataType: "json", + contentType: "application/json", error: function(xhr, type, message) { + //we had an error, it could be that we're talking to an old version of elasticsearch that doesn't support cross origin requests with a contentType set, so try again without it. if("console" in window) { - console.log({ "XHR Error": type, "message": message }); + console.log({ "XHR Error": type, "message": message, "retrying": true }); } + var repeatRequestParams = this; + delete repeatRequestParams['contentType']; + repeatRequestParams['error'] = function(xhr, type, message) { + if("console" in window) { + console.log({ "XHR Error": type, "message": message, "retrying": false }); + } + } + $.ajax(repeatRequestParams); } }, params) ); },