send()
et la méthode POSTxhr.open("POST","allerRetour2.php"); xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded"); xhr.onreadystatechange = function() { if (xhr.readyState==4) { alert(xhr.responseText); } } xhr.send("info1=chaine&info2=3");
<?php header("Content-Type: text/plain"); if (isset($_POST['info1']) && isset($_POST['info2'])) { echo "Le serveur a reçu info1="; echo $_POST['info1']; echo " et info2="; echo $_POST['info2']; } ?>