document.location.reload () does not re-send post same as refreshing page

1

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

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

I do not know if it's necessary, but in backend I'm using php

    
asked by anonymous 17.09.2014 / 19:45

2 answers

3

The MDN documentation about the Location.reload() method is unclear on this, but this method only reloads the current page using the GET method. The action of calling this method is almost the same as clicking the refresh button in your browser.

I believe that with this you have the following options:

  • Create a form invisible with POST parameters and perform one submit it using JavaScript;
  • Transform the parameters of POST into URL parameters ( ?param=valor ) and make a new request GET ;
  • Use AJAX ;

Similar SOEn question:

17.09.2014 / 20:07
1

Friend. I did not quite understand your questioning. 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 do you want to do?

On this link there is something similar: Jquery document.location.reload () doesn 't work correctly

    
17.09.2014 / 19:52