我正在对要在浏览器中呈现的另一个 php 文件进行POST。 jquery post 函数不会重定向到另一个页面。它期望 app-display.php 文件向它返回数据。看看代码。
echo '<div class="showcase_URL"><a class="purl" name="'.$row->num.'" href="#">PROJECT URL</a></div>';
到目前为止,我在 javascript 中拥有的是:
$(".showcase_URL a").click(function() {
//alert($(this).attr("name"));
var number = $(this).attr("name");
$.post(
"app-display.php",
{app: number},
function(data){
top.location.href = 'app-display.php';
});
});
我在 app-display.php 中的内容:
$query = 'SELECT num, title, thumb_url, url, type, cat, dated, details FROM app WHERE `num` = "$_POST[app]"';
但它目前给我的页面没有 app-display.php 的内容。正在加载页面的所有其他片段:页眉、页脚等。 我得到的 PHP 响应(在 Firebug 中)是页面的正常 html。
我应该怎么做?
最佳答案
只需使用普通的 <form action="app-display.php">
这样你就不需要取回数据。
关于PHP POST 响应,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2440071/