【发布时间】:2014-05-15 15:50:48
【问题描述】:
我放了一个循环来获取我数据库的所有值。然后,在每一行的最左边有一个按钮可以打开另一个页面以查看来自特定用户的所有数据库。我的问题是,当您单击我的按钮时,会出现一个函数(函数 ouvrirEditFormulaire),而我要做的是获取 4 个值并将其发送到该页面:acceptation.php。因此,在我的函数中,我打开了一个新窗口,然后使用 ajax 将我的数据发送到 eFormulaire.php,然后我尝试在我的另一个页面(acceptation.php)中对一个 div 进行内部 HTML,但没有任何反应。我能做的最多就是在我的第一页内插入一个 div(当你点击按钮时)......有没有办法将数据发送到我的 acceptation.php ???
我的 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'];
?>
【问题讨论】:
-
它看起来不像 ajax 对我来说