Does submit() function has a callback?

Posted by ecu on Stack Overflow See other posts from Stack Overflow or by ecu
Published on 2010-06-17T19:18:29Z Indexed on 2010/06/17 19:23 UTC
Read the original article Hit count: 117

Filed under:
|
|
|

Hi, I have this code:

setMyCookie('name','value_1');
$('.myform').submit();
setMyCookie('name','value_2');

Problem: Webkit browsers seem to update 'MyCookie' with 'value_2' before the form gets submited, or in the exact moment it is being submited, so wrong cookie value is sent with it. I want to change cookie value to 'value_2' immediately after the form is submited so the cookie is ready for another request.

The following code works fine, but I don't think using timeout() is the best solution. Maybe there is another way to solve this problem?

setMyCookie('name','value_1');
$('.myform').submit();
setTimeout(function(){setMyCookie('name',value_2);},100);

Thanks.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about jQuery