简体   繁体   中英

Passing PHP $_POST to Ajax Call

I have a Page A that a user sets their filters on which then posts the data to a new tab for processing in an EventViewer tab (Page C). However, as the page takes a long time to process in some cases, I want to add a loader Page B in between, however, I am struggling to work out how to pass the $_POST data to an AJAX call to be made to PageC.

The flow is as follows:

  1. User enters filters on Page A
  2. PageA posts data to a new tab Page B (Loader with a spinner page)
  3. When on Page B an AJAX call is made to load the actual data from Page C in the background by passing the data originally set in Page A.

Please help! Or suggest better ways of doing this flow.

You can't access browserside the $_POST variables.

Read the textboxes with jquery/Javascript, and then make an ajax request to the other page with your (in js-vars saved) POST-Parameter.

https://www.w3schools.com/jquery/jquery_ajax_get_post.asp

So: pass the parameter to PageB, make in PageB an ajax request to pageC, which just returns the data, then display the data in in PageB, as soon they are returned.

That you have access to the parameters from PageA in PageB:

var Test = <?php echo $_POST["test"]; ?>;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM