como estoy aprendiendo estoy haciendo pruebas tengo este codigo:
Código HTML:
Ver original
<html> <head> <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); } } } </script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> </head> <body> <select id="cat1" onchange="requestPOST();"> </select> <br /> <select id="cat2"> </select> </body> </html>
y el php
Código PHP:
Ver original
<?php $cat = $_POST["cat1"]; echo $cat; ?>
y el alert me duevelve vacio, que puede ser?