我有一个关于通过AJAX向2外部php页面发送变量的问题,所以我在fab.php中有一个变量,将在data2.php和data3.php中使用。
所以fab.php中的ajax是这样的
$(function(){
// SHOW RECORD
$('#show').click(function(){
$.post('data2.php',
{action: "show",
"hm":$('#headmark').val()},
function(res){
$('#result').html(res);
});
});
});我成功地在data2.php中使用了"hm“
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"]}'";在这个页面中,应该显示与"hm“值相对应的结果,用户可以直接更新它,并将更新后的值发送回data3.php中的服务器,为了更新它,我仍然需要选中的"hm”值,以便在data3.php中进行更新过程。
我试过这种方法,但不起作用
$(function(){
// SHOW RECORD
$('#show').click(function(){
$.post('data2.php', 'data3.php',
{action: "show",
"hm":$('#headmark').val()},
function(res){
$('#result').html(res);
});
});
});发布于 2014-04-11 04:01:02
首先将$.ajax请求发送到data2.php使用会话
Data2.php中的
<?php
session_start(); #start session here
#declare session varible and assign POST value to session
$_SESSION['getvalue'] = $_POST['getValue'];中的data3.php
<?php
session_start(); #start session here
#And use $_SESSION['getvalue'] nowhttps://stackoverflow.com/questions/23003131
复制相似问题