ficou assim:
<div id="texto"> <form name="form1" method="post" action="exp.php?acao=take"> <input name="radio" type="radio" checked="checked" value="escolha 1" /> escolher 1?</label> <input name="radio" type="radio" value="escolha 2" /> escolher 2?</label> <input name="radio" type="radio" value="escolha 3" /> escolher 3?</label> <input name="radio" type="radio" value="escolha 4" /> escolher 4?</label> <input type='submit' value=' submeter '> </form></div> </body> </html> <?php if(@$_GET['acao']=="take"){ echo $_POST['radio']; } ?>
ok, funcionou perfeitamente, mas como colocar ajax nisso pra atualizar dados sem atualizar a página?
tentei assim:
<html> <head> <title>document</title> </head> <body> <script language="JavaScript"> <!-- var xmlhttp; function verificar(form) { var body = ""; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Seu navegador não suporta XMLHttpRequest."); return; } xmlhttp.open("GET", "index.php?acao=take", true); xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate"); xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0"); xmlhttp.setRequestHeader("Pragma", "no-cache"); xmlhttp.onreadystatechange = processReqChange; xmlhttp.send(null); } function processReqChange() { if(xmlhttp.readyState == 1){ document.getElementById("texto").innerHTML = "Carregando...!"; } if (xmlhttp.readyState == 4) { if (xmlhttp.status == 200) { document.getElementById("texto").innerHTML = xmlhttp.responseText; } else { alert("Problemas ao carregar o arquivo."); } } } //--> </script> <div id="texto"> <form name="form1" method="post"> <input name="radio" type="radio" checked="checked" value="escolha 1" /> escolher 1?</label> <input name="radio" type="radio" value="escolha 2" /> escolher 2?</label> <input name="radio" type="radio" value="escolha 3" /> escolher 3?</label> <input name="radio" type="radio" value="escolha 4" /> escolher 4?</label> <input type="button" onclick="verificar(this.form)" value=" Votar "> </form></div> </body> </html> <?php if(@$_GET['acao']=="take"){ echo $_POST['radio']; } ?>
Mas como podem ver apareceu o seguinte erro:
Notice: Undefined index: radio in c:\arquivos de programas\easyphp1-7\www\tests\index.php on line 73
onde eu tenho que arrumar pro ajax funcionar?
Desde já obrigado.
Edição feita por: automouse, 21/05/2006, 21:16.