setTimeout() not working when window.location... is next line in code

setTimeout() not working when window.location... is next line in code

The following code is intended to:

1.  update() a MySql database                              -- update()
2.  update the values in an account  form            -- retData()
3. display success message for 2 seconds         -- successMsgShow()  
4. return to same page to repeat as necessary   -- window.location ...

PROBLEM: If window.location.href="AccountRevise.html?recId="+recId+"&company="+company; is commented out the time delay part of successMsgShow() works as expected with a 2 second delay.. Otherwise there is no delay.

Any help appreciated.

R.


  1. <script type="text/javascript" >

        function update() {

            var str = $('#account').serialize();
            $.post("AccountRevise.php", str, retData, "json");   
                
                function retData() {
                    $.each(retData, function(key, value) {
                        $("#"+key).val(value);
                    }); // each       
                 }; // retData
        }; // upDate

    </script>

    <!--   ===============  Success Message with Time Delay  =================== -->

    <script type="text/javascript">

        function successMsgShow() {
       
         $("#msgbox").append('<h3> <span style="color:red">Data Revised Successfuly</span></h3>');
        setTimeout(successMsgHide, 2000);
    }

        function successMsgHide() {
       
            $("#msgbox").hide();     

        }
       
    </script>

     
     <script type="text/javascript">
         
         $('button[name="front"]').click(function() { location.href='AccountsFrontEnd.php'}); 
        $('button[name="account"]').click(function() { location.href='PickCategory.php'});
      







































  2.  $('button[name="revise"]').click(function()    {
                 update();
                 successMsgShow();
                 window.location.href="AccountRevise.html?recId="+recId+"&   company="+company;              
         });




         
    </script>