Yo uso este "template:" pero en js
Código HTML:
Ver original <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<script type="text/javascript">
function createREQ() {
try {
req = new XMLHttpRequest(); /* p.e. Firefox */
}
catch(err1){
try {
req = new ActiveXObject('Msxml2.XMLHTTP'); /* algunas versiones IE */
}
catch (err2) {
try {
req = new ActiveXObject("Microsoft.XMLHTTP"); /* algunas versiones IE */
}
catch (err3) {
req = false;
}
}
}
return req;
}
function someXHTTPfunction(){
var http = new createREQ();
http.open("POST", "somePHPscript.php", true);
http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
var var1 = document.getElementById("someElement1").value;
var var2 = document.getElementById("someElement2").value;
http.send("var1="+var1+"&var2="+var2);
http.onreadystatechange = function(){
if(http.readyState == 4 && http.status == 200){
httpXML = http.responseXML;
}
};
//ALL THE XML VALUE IN: httpXML
}
<input type="text" id="someElement1" /><br/> <input type="text" id="someElement2" /><br/> <button onclick="someXHTTPfunction();">MAKE SOME XHTPP
</button>
y en php
Código PHP:
Ver original<?php
$posts = array($_POST["var1"], $_POST["var2"]); //here you can use the posts as array
//here the PHP code...
//here below create the xml response....
header("Content-type: text/xml");
echo '<?xml version="1.0" encoding="UTF-8" ?>
<posts>
<ele1>
'.$posts[0].'
</ele1>
<ele2>
'.$posts[1].'
</ele2>
</posts>';
?>
eso uso yo y me anda de 10, saludos