2

Is it possible to replicate f5 action to link using jquery? I need to refresh the page and resend data using this link, I have tried :

location.reload(true); or document.location.reload(); or $.f5();

But did not satisfy me.

Steps to reproduce using f5 key : 1. fill form then submit 2. press f5 - confirm box will appear

The page that you're looking for used information that you entered. Returning to that page might cause any action you took to be repeated. Do you want to continue?

Monnster
  • 625
  • 7
  • 16
  • have you tried `window.location.reload();` ?? – zzlalani Apr 10 '14 at 07:07
  • Do you have a html form? If yes you could just submit that one. Also please setup a [jsFiddle](http://jsfiddle.net/) with your code. – RononDex Apr 10 '14 at 07:07
  • tried window.location.reload(); but did not work - it did not resend post data. will try to set code using jsFiddle, by the way I'm using one page, after the code submission, I'm not longer showing the form, so I couldn't just do form.submit. – Monnster Apr 10 '14 at 07:15

2 Answers2

1

try using

window.location.reload(true);

if it wont resubmit the form. you have two more options.

  1. Submit the form using ajax after once submitted and resubmit the form and second time refresh the page or clear the form
  2. Or you can keep the post data in some session or in the post array [server side code] and refill the form and resubmit,

Make sure you keep the track of numbers of submit you made since it will cause you trap in some recursion.

BUT why you want to resubmit the form you already have data you can perform both actions,

And if you have to post the form to some other action for second submit you can do the same may be using CURL at server side.

zzlalani
  • 22,960
  • 16
  • 44
  • 73
  • tried window.location.reload(); but did not work - it did not resend post data. – Monnster Apr 10 '14 at 07:12
  • @Monnster try giving `true` in argument, and also check the update – zzlalani Apr 10 '14 at 07:19
  • I have server validation that could detect if updates will have duplication. e.g. a-1, b-1, c-1 and user would like to change all letters to d. On that page, I listed all conflicts and user can change the numbers on the fly to avoid dups, after changing the numbers, user need to click f5 to resend all this list and change the letter to d. So would like to replicate that f5 function tru link click. – Monnster Apr 10 '14 at 07:43
0

Try this:

window.location.reload(false); 
// If we needed to pull the document from
//  the web-server again (such as where the document contents
//  change dynamically) we would pass the argument as 'true'.

source

Community
  • 1
  • 1
Bhojendra Rauniyar
  • 83,432
  • 35
  • 168
  • 231