Document.location.Reload() does not re-post equal to page refresh

Asked

Viewed 690 times

1

I had to make some changes to a part of the system, and in that part before I was passing the data only by GET, but now I can go through both GET and POST, but I’m having a problem with the document.location.reload() that does not re-upload the POST data like the ones in GET. It should have the same effect as pressing the F5 that re-sends the data.

Does anyone know how I can at least try to solve this?

I don’t know if it’s necessary, but in backend I’m using php

  • 1

    I believe that because GET was passed through the URL, when updating, the data remained the same there. Already the post, the data forms are usually lost with refreshs.

  • Probably the fields (textFields) are being cleared when vc gives the first Submit.

2 answers

3

To MDN documentation on the method Location.reload() is not clear about this, but this method just reload the current page using the method GET. The action of calling this method is almost the same as clicking the refresh browser.

I believe with this, you have the following options:

  • Create a form invisible with the parameters of POST and carry out a Ubmit in it using Javascript;
  • Transform the parameters of POST in URL parameters (?param=valor) and make a new request GET;
  • Utilise AJAX;

Similar question by Soen:

  • So, these links I had even seen before, but I haven’t been able to, but I still appreciate it. And the action is not so much the same, because when I click refresh button still passes the post parameters.

  • I edited correcting the refresh button statement. Anyway, using an invisible form you can not achieve what you want?

1

Friend. I didn’t understand your question very well. I’m sorry if I’m wrong.

You want to pass information via POST or GET. Have you considered using Ajax for this?

$.ajax({
        url:'minha_pagina.php',
        type:'POST',
        data:'info=' + info
});

What specifically you want to do?

In this link there is something similar: Jquery Document.location.Reload() doesn’t work correctly

  • So, in my case I’m passing information now by get, now by post. I’m doing all the treatments and it’s working.

  • @Marcelodiniz As the colleagues above spoke, when a refresh is executed the form fields are cleared. Then you would have to do as in the Link I posted there, add the parameters to the link as you run.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.