Ver Mensaje Individual
  #4 (permalink)  
Antiguo 01/04/2008, 11:31
Avatar de MaBoRaK
MaBoRaK
 
Fecha de Ingreso: abril-2003
Ubicación: La Paz - Bolivia
Mensajes: 2.003
Antigüedad: 21 años
Puntos: 35
Re: Ajax en Java Web

loading.............


Código:
<HTML>
<head>

<script type="text/javascript">
	var XMLHttpObject = function()
	{
		try{
			var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch(e)
		{
			try
			{
				var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch(e)
			{
				var xmlhttp = false;
			}
		}
		return (!xmlhttp && typeof XMLHttpRequest!='undefined')?
		new XMLHttpRequest():xmlhttp || new function(){};
	}
	var rpc = new XMLHttpObject();
	rpc.open("POST","ejemplo1_server.php",true);
	rpc.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
        var username = document.getElementById('username').value;
// y así creas para los otros datos
	rpc.send(encodeURI("username="+username+"&otrovar=otra_variable"));
	rpc.onreadystatechange=function()
	{
		if(rpc.readyState===4)
		{
			alert(rpc.responseText);
		}
	}
</script></head><body>
AQUI TU FORMULARIO,
cada elemento (INPUT) debe tener un ID
por ejemplo

username: <input type="text" id="username" >

</body>
</HTML>

Ahora bien luego bajas firebug ( http://getfirebug.com ) si no usas firefox para desarrollo PUEDES MORIR EN PAZ.

en la pestaña CONSOLE, podrás ver las variables que envias por POST y bueno... ya en tu pagina jsp caturas las variables POST y bueno.. creo que eso es todo.


connection closed.
__________________

Maborak Technologies