我放了一個循環來獲取我的數據庫的所有值。然後,在每一行的最左邊有一個按鈕來打開另一個頁面,以查看來自特定用戶的所有數據庫。我的問題是,當你點擊我的按鈕時,會出現一個函數(函數ouvrirEditFormulaire),我想要做的是獲取4個值並將其發送到該頁面:acceptation.php。所以在我的函數中,我打開一個新窗口,然後用ajax將我的數據發送到eFormulaire.php,並試圖在另一個頁面(acceptation.php)中innerHTML div,但沒有任何反應。我能做的最多的是在我的第一頁中innerHTML div(當你點擊按鈕時)......是否有任何方法將數據發送到我的acceptation.php?如何使用ajax將數據從頁面發送到另一頁
我的AJAX:
function ouvrirEditFormulaire(id,date,heure,client) {
window.open('concessionnaire/acceptation.php','mywin','left=20,top=20,width=650,height=730');
var xhr = new XMLHttpRequest();
xhr.open("POST","concessionnaire/eFormulaire.php",true);
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
xhr.onreadystatechange = function() {
if(xhr.readyState == 4 && xhr.status == 200) {
document.getElementById('divAnotherPage').innerHTML = xhr.responseText;
}
}
xhr.send("id="+id+"&date="+date+"&heure="+heure+"&client="+client);
}
eFormulaire.php:
<?php
include_once('../connect.php');
$object = new User;
$id = $_POST['id'];
$date = $_POST['date'];
$heure = $_POST['heure'];
$client = $_POST['client'];
?>
它看起來不像我的阿賈克斯 – meda