Reputation: 199
I have a question regarding sending variable thru AJAX to 2 outside php pages, So I have a variable in fab.php
that will be used in data2.php
and data3.php
So the ajax in fab.php
is this
$(function(){
// SHOW RECORD
$('#show').click(function(){
$.post('data2.php',
{action: "show",
"hm":$('#headmark').val()},
function(res){
$('#result').html(res);
});
});
});
And I successfully able to use "hm" in data2.php
with this
if($_POST['action'] == 'show'){
$sql = "SELECT * FROM SUB_MASTER_DRAWING
// "hm" is passed from the previous page
WHERE SUB_MASTER_DRAWING.HEAD_MARK = '{$_POST["hm"]}'";
In this page the results corresponded with "hm" value should be shown and user can direcly update it and send the updated value back to the server in data3.php
In order to update it, I still need the "hm" value that is selected to make the update process in data3.php
I Tried this method but it doesnt work
$(function(){
// SHOW RECORD
$('#show').click(function(){
$.post('data2.php', 'data3.php',
{action: "show",
"hm":$('#headmark').val()},
function(res){
$('#result').html(res);
});
});
});
Upvotes: 2
Views: 64
Reputation: 6887
First Send your $.ajax
request to data2.php
use SESSION
In data2.php
<?php
session_start(); #start session here
#declare session varible and assign POST value to session
$_SESSION['getvalue'] = $_POST['getValue'];
In data3.php
<?php
session_start(); #start session here
#And use $_SESSION['getvalue'] now
Upvotes: 1