【发布时间】:2015-03-11 06:16:37
【问题描述】:
如何通过ajax调用将请求重定向到指定的php页面,下面是我的代码结构
index.html
<html>
<script>
function shift(str)
{
$.ajax({
url: 'destination.php',
type:'POST',
data: {q:str}
}).done(function( data) {
$("#result").html(data);
});
return false;
}
</script>
<body>
<input type='button' value='test' onclick="shift('test');">
<div id='result'></div>
</html>
destination.php
<?php
$string=$_REQUEST['q'];
if($string=="something")
{
header('something.php');
}
else
{
echo "test";
}
?>
这是我的代码结构,如果发布的字符串与标题功能相同,那么标题功能应该可以工作,否则会回显某些内容,但标题功能不能通过 ajax 工作
【问题讨论】:
-
这可能有用.. stackoverflow.com/questions/199099/…>
标签: javascript php jquery ajax