Friday, 23 August 2013

jquery ajax asynchronous requests error

jquery ajax asynchronous requests error

at the beginning I would like to say sorry for my bad english.
jquery v2.0.0 in Google Chrome, Mozilla Firefox, Opera last versions
Today I had a problem
timer_multy_update = setInterval(
function()
{
$.get(
'test.php',
function (result){
parseAndUpdateData(result);
},
"json"
);
}, 500)
The problem is that if the server hangs (I don't know how to say it
correctly), i.e. time to get answer from the server more the 0,5 second,
but timer not stay and continues to send request, so before the server
answer it can be send 2-4 request, all this answer return for a little
time and, now a problem, in firebug all request correct, but variable
result contains only one answer from the first answer from the server.
maybe I did not express myself clearly, I want to say that 2-4 request to
the server return different answer, but in result gets all 2-4 times the
first answer from the server, and it is big problem.
I tried to find information on the Internet, but found nothing.
I do not know why but the first thought was that the error in jquery, I
began to look at the source code, and found some mention about heder and
it's hashes. So i try to change my script and find to way
$.get
(
'/php/mine/update_cells.php',
't='+Math.random(),
function (result)
{
parseAndUpdateData(result);
},
"json"
);
it works correctly so I want to now, bug it is or my mistake and not
understanding

No comments:

Post a Comment