javascript - JQuery .ajax 304 Not Modified parseerror -
i have single page javascript webapp rolled scratch (i know know)
we have central set of ajax defaults work follows:
model.defaultsloader = function(message, config, callback, async, delay){ if(typeof delay === "undefined"){ delay = 3000; } var loader = new loader(delay, message); defaults = { type: 'get', beforesend: function(jqxhr){ var token = $("meta[name='csrf-token']").attr("content"); jqxhr.setrequestheader("x-csrf-token", token); }, success: function(response){ loader.stop(); if(callback){ callback(response); } }, error: function(jqxhr, textstatus, errorthrown ){ if (jqxhr.status === 401) { document.location = "/"; } else if(!death && jqxhr.status !== 200) { loader.showerror(textstatus + ": " + errorthrown); support.bugreport( account.email + ', ' + message + ': ' + textstatus + ': ' + errorthrown); } }, datatype: 'json', async: async }; for(var param in config){ defaults[param] = config[param]; } return defaults; };
the problem running started having problems 304 not modified responses our end ending in error handler rather success handler. reason 'parseerror'... whatever reason jquery attempting parse response body our server on 304 response (which "" aka nothing.) know empty string not valid json, don't understand why jquery trying parse empty string rather loading cached value... causing rather troublesome behavior on our production servers in circumstances.
i've included screen shot of dev console of print out did purposes of debugging. you'll have excuse it's unfolded minified code.
edit: seems weird debugger showing response code of 200 while chrome dev tools showing response code of 304.
Comments
Post a Comment