Ver Mensaje Individual
  #16 (permalink)  
Antiguo 09/01/2008, 14:33
pr0
 
Fecha de Ingreso: marzo-2004
Mensajes: 687
Antigüedad: 20 años, 1 mes
Puntos: 28
Re: Como enviar un array u objeto mediante xajax?

Lo he probado yo mismo y funciona. Tu pagina procesa_datos.php tiene que quedar asi, copiala tal cual:

Código HTML:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Documento sin t&iacute;tulo</title>
<script type="text/JavaScript" src="prototype.js"></script>
<script language="javascript">
function envia_datos(){
   var capa = $('micapa'); //esto es equivalente a document.getElementById('id_capa')
   var nombre = $('nombre').value;
   var apellido = $('apellido').value;
   var pars = 'nombre=' + nombre + '&apellido=' + apellido;
   if (!capa) return false;
    new Ajax.Updater(capa, 'procesa_datos2.php'{
        method: 'get',
        parameters: pars
    });
} 
</script>
</head>

<body>
<form method="get">
<table width="60%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>Nombre</td>
    <td><label>
      <input type="text" name="nombre" id="nombre" />
    </label></td>
  </tr>
  <tr>
    <td>Apellido</td>
    <td><label>
      <input type="text" name="apellido" id="apellido" />
    </label></td>
  </tr>
  <tr>
    <td><label>
      <input type="button" name="enviar" id="enviar" value="Enviar" onClick="envia_datos()" />
    </label></td>
    <td>&nbsp;</td>
  </tr>
</table>
</form>
<div id="micapa"></div>
</body>
</html>