Usamos cookies para medir audiência e melhorar sua experiência. Você pode aceitar ou recusar a qualquer momento. Veja sobre o iMasters.
Salve Galera!
Bom, estou apanhando um pouco com o ajax, carregar conteúdo passando vas por GET beleza...
Agora passando por POST, ta meio dificíl!
Escrevi esse código, e gostaria que alguém altera-se ele para que o form seja enviado atraves de ajax!
<script>function xmlhttpInit () { var req; try { req = new ActiveXObject("Microsoft.XMLHTTP"); } catch ( e ) { try { req = new ActiveXObject("Msxml2.XMLHTTP"); } catch ( ex ) { try { req = new XMLHttpRequest(); } catch ( exc ) { alert("Seu browser não suporta 'XMLHTTP'!"); req = null; } } } return ( req );}//function carregaHTML ( sURL, sID ) { var xmlhttp = xmlhttpInit(); if ( xmlhttp ) { xmlhttp.open( "GET", sURL, true ); xmlhttp.onreadystatechange = function () { if ( xmlhttp.readyState == 4 ) { document.getElementById( sID ).innerHTML = unescape( xmlhttp.responseText.replace(/\+/g, " ") ); } }; xmlhttp.send( null ); } delete xmlhttp;}</script><form action="" method="post" name="frm"> <input type="text" name="txt_01" maxlength="255"> <BR /> <input type="text" name="txt_02" maxlength="255"> <BR /> <input type="text" name="txt_03" maxlength="255"> <BR /> <textarea name="msg_01"></textarea> <BR /> <textarea name="msg_02"></textarea> <BR /> <textarea name="msg_03"></textarea> <BR /><BR /> <input type="submit" value="Enviar"></form>
Parece tão simples!
VLW!
Carregando comentários...