Estimados tengo problema con post en ajax
como estoy aprendiendo estoy haciendo pruebas tengo este codigo:
Código HTML:
Ver original
<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;
}
http = new createREQ();
function requestPOST(){
cat = document.getElementById("cat1").value;
http.open("POST", "includes/categoria.php", true);
http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
http.onreadystatechange = changeCat2;
http.send("?cat1="+cat);
}
function changeCat2(){
if(http.readyState == 4){
if(http.status == 200){
text = http.responseText;
alert(text);
}
}
}
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<select id="cat1" onchange="requestPOST();">
y el php
Código PHP:
Ver original<?php
$cat = $_POST["cat1"]; echo $cat;
?>
y el alert me duevelve vacio, que puede ser?