javascript - jquery ajax asynchronous requests error -
at beginning sorry bad english.
jquery v2.0.0 in google chrome, mozilla firefox, opera last versions
today had problem
timer_multy_update = setinterval( function() { $.get( 'test.php', function (result){ parseandupdatedata(result); }, "json" ); }, 500)
the problem if server hangs (i don't know how correctly), i.e. time answer server more 0,5 second, timer not stay , continues send request, before server answer can send 2-4 request, answer return little time and, problem, in firebug request correct, variable result contains 1 answer first answer server. maybe did not express myself clearly, want 2-4 request server return different answer, in result gets 2-4 times first answer server, , big problem.
i tried find information on internet, found nothing.
i not know why first thought error in jquery, began @ source code, , found mention heder , it's hashes. try change script , find way
$.get ( '/php/mine/update_cells.php', 't='+math.random(), function (result) { parseandupdatedata(result); }, "json" );
it works correctly want now, bug or mistake , not understanding
this isn't bug, it's caching. it's lot more efficient browser cache resource while have go , every time wants it. fine static resources, i.e. ones don't change web service returns different results same url want disable caching. if control server side code, add cache-control: no-cache
header response. can disable caching in jquery far know, have use ajax()
function - there's no way get()
.
$.ajax({ url: "/php/mine/update_cells.php", success: function(result){ parseandupdatedata(result); }, cache: false, datatype: 'json' });
Comments
Post a Comment