[AJAX] Envoi des valeurs via la technologie ajax
Bonsoir cher développer
Je viens de crier deux page php
une page
test.php contient
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
<html>
<head></head>
<script type="text/javascript">
<!--
function getXMLHttpRequest() {
var xhr = null;
alert("ip");
if (window.XMLHttpRequest || window.ActiveXObject) {
if (window.ActiveXObject) {
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
} else {
xhr = new XMLHttpRequest();
}
} else {
alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
return null;
}
alert("ip");
return xhr;
}
function request() {
alert("ip");
var ip=<?php echo $_SERVER["REMOTE_ADDR"]; ?>;
var xhr = getXMLHttpRequest();
var nom="dar";
xhr.onreadystatechange = function()
{
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0))
//readData(xhr.responseXML);
alert("koko");
};
xhr.open("POST", "google.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("ip=" + ip);
xhr.send("nom=" + nom);
alert("ip");
}
//-->
</script>
<style type="text/css">
<!--
#aa {
position:absolute;
left:130px;
top:63px;
width:197px;
height:142px;
z-index:1;
color: #0E0E0E;
background-color: #7C7C7C;
}
-->
</style>
<body >
<div id="aa" onclick="request();"> koko
</div>
</body>
</html> |
et la page google.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
<!--
To change this template, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
</head>
<body>
<?php
$ip=$_POST["ip"];
echo $ip;
include_once 'AccB.php';
$Acc=new AccB();
$re="INSERT INTO `google` (`ip`) VALUES ('$ip')";
$Acc->Exec($re);
?>
</body>
</html> |
Le problème c'est que quant je clic sur la div sa ne passe pas les donnée vers la page google.php
Cordialement Ryodo