我将数据发布到一个页面,之后我想同时导航到另一个页面。我使用javascript发布数据,我检查了它是否响应其值,当我只发送发布数据时,它运行良好,但当我重定向到另一个页面并试图访问这些发布数据时似乎没有设置。顺便说一下,我写的是一个类似的javascript
function getsupport ( selectedtype )
{document.folderCreate.supporttype.value=选定的类型;document.folderCreation.submit();document.location。href="../../index.php";
}
形式:
<form action="index.php" name="folderCreation" method="POST" >
<input type="hidden" name="supporttype" /><?php
while($row = mysql_fetch_array($rs))
{
$filePath=$row['pathFromImages'];
$id=$row['id'];
?>
<a href="javascript:getsupport('<?php echo $filePath;?>')" ><?php echo $filePath;?></a>
</br>
<?php
当行:document.location.href="../../index.php";不在那里。为什么不起作用?。。
提前谢谢。
这段代码应该可以工作:
<form action="page2.php" method="POST">
<input type="text" name="a" onsubmit="postdata($(this)); return true;" />
<input type="submit" />
</form>
javascript函数:
function postdata(x){ $.post('page1.php', {a: x.a.val()}); }