我正在嘗試加載B.php從a.php只會在功能執行後,並從通過使用交陣列一些數據a.php只會到乙.php在同一時間內。通過數據
代碼列表如下 a.php只會
<script type="text/javascript">
alert_for_the_fucntion();
window.location.href = "B.php";
function alert_for_the_fucntion() {
$.post("B.php", {action: 'test'});
}
</script>
B.php
<?php
if (array_key_exists("action", $_POST)) {
if ($_POST['action'] == 'test') {
echo 'ok';
}
}
?>
用於測試目的,我想呼應的B.php東西。但目前這是行不通的。我犯過什麼錯誤嗎?或者是否有任何可能的方法來做到這一點。
什麼是'B.php.php'? –
有一個錯字應該是'window.location.href =「B.php」;'而不是'window.location.href =「B.php.php」;'爲什麼要重定向? – funilrys
問題是關於window.location.href,這會讓你在進行ajax調用之前更改頁面。 – Salketer