2014-04-03 37 views
0

我放了一個循環來獲取我的數據庫的所有值。然後,在每一行的最左邊有一個按鈕來打開另一個頁面,以查看來自特定用戶的所有數據庫。我的問題是,當你點擊我的按鈕時,會出現一個函數(函數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']; 
?> 
+0

它看起來不像我的阿賈克斯 – meda

回答

1

你不需要AJAX這個:

function ouvrirEditFormulaire(id,date,heure,client) { 
    var url = 'concessionnaire/acceptation.php';  
    window.open(url + "?id="+id+"&date="+date+"&heure="+heure+"&client="+client, 'mywin','left=20,top=20,width=650,height=730'); 
} 

現在你打開一個新頁面,而不參數,然後在不同的請求中發佈到同一頁

您還將有機會在acceptation.php上$_GET[xxx]

如果您希望打開acceptation.php,同時保留在當前頁面上並以某種對話框格式顯示結果,AJAX調用可能會很方便。

+0

太好了,一百謝謝你了老金。它幫助了我很多!謝謝你的解釋:) –

相關問題