Use client side values ​​in second php file via Ajax

I have three php files.

filter.php - to send Ajax request and get response insert.php - to store Ajax response getResponse.php - to use stored Ajax response. 

The main goal of all this is to use client-side values ​​using PHP code, because the server and the client cannot exchange variable values ​​with each other.

Expected: the response should be stored in the php variable in getResponse.php.

I got an array response in insert.php, but how can I use in getResponse.php?

For instance,

---------- filter.php ----------

 <script> $.ajax({ type: "POST", url: "filter.php", data: { name: tp, country:"test"}, success:function(response) { var res = response; $.ajax({ type: "POST", url: "insert.php", data: { res: res }, success:function(data){ alert(data); } }); }); <script> 

-------- insert.php ----------

 if ($_POST) { if ($_POST['id1'] !== "") { echo $_POST['id1']; } } 

-------- getResponse.php ----------

Code to get array response from Ajax through filter.php and insert.php?

You must save this array value and manipulate accordingly.

Thanks for your help in advance!

0
source share
1 answer

Here's the answer:

 <script> $.ajax({ type: "POST", url: "filter.php", data: { name: tp, country:"test"}, success:function(response) { var res = response; $.ajax({ type: "POST", url: "getResponse.php", data: { res: res }, success:function(data){ alert(data); } }); }); </script> 
0
source

All Articles