1

I have a page called index.php where I have some forms where the user must input information.
On this page I have this JQuery functions.

 else if (result == 3)
 {

     jQuery.get('sample.txt', function(data) {
         alert(data);
     });

 }

where the file sample.text its shown on an alert.

But, I have a page called download.php. When the user click on "submit" at page "index.php" , its send to the page "download.php", the values sent using Ajax POST.

var formData = new FormData($('#form_principal')[0]);
     $("#loading").show();

    setTimeout(function() {
        $.ajax({url: "/tkclientespdo/etiquetaslog/000/0000/download.php",
                  type: "post",

                  data: formData,
                  cache: false,
                  async:true,
                  contentType: false,
                   processData: false,
                  success: function(result)

on page "download.php" i have this variable :

$horaenvio = date("dmYGis");

after this variable i have a code :

echo 3;

that return the function at index.php . but i wanna change 'sample.txt" for the variable "$horaenvio".

someone could help.

Prashanth Benny
  • 1,523
  • 21
  • 33
Joe Doe
  • 57
  • 10

1 Answers1

0

You can use localStorage and storage event or SharedWorker to store the value data at index.php, and get the value at download.php, then .append() data to the FormData object, then echo the proper POST value.

guest271314
  • 1
  • 15
  • 104
  • 177
  • could u made a example ? – Joe Doe Aug 04 '17 at 15:03
  • @Kamikaz0r Is `download.php` expected to be visited after `.index.php`? – guest271314 Aug 04 '17 at 15:08
  • @Kamikaz0r See [Can we refer to JavaScript variables across webpages in a browser session?](https://stackoverflow.com/questions/36146595/can-we-refer-to-javascript-variables-across-webpages-in-a-browser-session/), [JavaScript Session storage variable on another page](https://stackoverflow.com/q/38034647/), [Can the mechanism that loads the worker in Shared Web Workers be modified?](https://stackoverflow.com/q/38938039/), [How to append an image from URL to a FormData - Javascript](https://stackoverflow.com/q/37241882/) – guest271314 Aug 04 '17 at 15:16