【发布时间】:2014-11-15 10:06:42
【问题描述】:
我看不出下面的代码有什么问题。我只是想将一个 php 变量提交到另一个 php 页面。请不要说会话,因为我知道肯定会话不会在这里为我工作。我想要的只是通过 ajax 将会话变量发送到下一个 php 页面,而用户不知道它。
<?php
session_start();
$fname=$_SESSION['mail'];
?>
<!DOCTYPE HTML>
<html>
<title>Addressbook</title>
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript">
$(function(){
$.ajax({
url:"DbManipulate.php",
type:"POST",
data:"source1:"<?php echo $fname ?>""
});
}
</script>
<link rel="stylesheet" type="text/css" href="crudstyle.css" />
</head>
<body>
<div id="hidden_form_container" style="display:none;"></div>
<div id="mhead"><h2>Your Adressbook</h2></div>
<div id="note"> <span> your addressbook is connected to our servers :) </span></div>
<?php
echo $fname;
?>
<table id='demoajax' cellspacing="0">
</table>
<script type="text/javascript" src="script.js"></script>
</body>
</html>
【问题讨论】:
-
试试
'source1:"<?php echo $fname ?>"'
标签: javascript php jquery ajax session