ajax - jQuery getScript() sometimes works fine, sometimes returns "parsererror" and TypeError Exception -
i have strange problem jquery (currently 1.9.1 version), using getscript() function load additional js library on demand. loads everytime same library same libraries, there no difference between multiple requests. returned server "application/javascript". use 1 browser these requests.
$.getscript(scripts[s], function(){ onscriptloaded(); }).done(function(script, textstatus) { console.log(textstatus); }).fail(function(jqxhr, settings, exception) { console.log(jqxhr, settings, exception); }); it runs fine, .done() called , textstatus success. however, 1 in 10 requests, fails , .fail() called - settings contains parsererror , exceoption contains typeerror {}.
i have no idea why happening, because 9 times out of 10 works fine. why fails, don't know. can shed light on problem ?
i glad hints or help.
ok, have found solution, not happy it, because don't know real cause of problem.
i used solution mentioned in answer: https://stackoverflow.com/a/2068597/385264
it's not answer, because have no idea, , why going on. glad got work, if explain it.
i hope, @ least, similar problem.
Comments
Post a Comment