Submit browser with jquery

When I submit the form, I show a “Wait” blocking message with the following code:

$(document).ready(function() { 
  $('form').submit(function() {
    $.blockUI({ message: "<h1 id='waitingmessage'>Plz wait ...</h1>" });
  });
}); 

This works for me.

If the user presses F5, the browser requests a retransmission. The user is allowed. But the above script no longer runs.

How can I trigger this retransmission using jquery so a wait message is shown?

thank

Chris

EDIT: Form submission refers to the same address as the form. I stand out only on the controller side between GET and POST. If it was a POST, I process the received data, otherwise I only show an empty form. The user is allowed to send data twice or often as required. Therefore, after the first POST, the user can press F5 to retransmit data, and he is fully allowed. It is just that the expectation does not appear anymore. So I need, maybe, a more general "onpost" solution. Is there something similar?

DECISION:

$(document).ready(function() { 
   $('form').submit(function() {
      $.blockUI({ message: "<h1 id='waitingmessage'>Bitte warten ...</h1>" });
   });

   $(window).keydown(function(event){
      if (event.keyCode == '116' && '${request.method}' == 'POST') {
         $.blockUI({ message: "<h1 id='waitingmessage'>Bitte warten ...</h1>" });
      }
   });
});

And request.method is installed on the server side and is either "GET" or "POST", so I know where the user came from.

+3
source share
3 answers

, . F5

<script type="text/javascript">
$(function ()
{
    $(window).keydown(function (e)
    {

        if(e.keyCode == 116){
            submitform();
            return false;
        }
        alert(e.keyCode);
    });
})

function submitform()
{
    alert("hello");
}
</script>

<form id="myform" action='test.php'>
    <input id="submit" type="submit" onclick="submitform(); return false;"/>
</form>
+2

, , F5, "", - POST , .

- :

  • GET: showForm.php( JS)
  • POST: sublitForm.php( )

F5, POST.

EDIT: HACK, Ajax $('#myForm').submit();. location.href .

, .

+1

jquery chech this link

0

All Articles