Ver Mensaje Individual
  #8 (permalink)  
Antiguo 26/03/2014, 13:57
bathorz
 
Fecha de Ingreso: agosto-2013
Mensajes: 150
Antigüedad: 10 años, 8 meses
Puntos: 29
Respuesta: No funciona código

Buenas. Dejado lo necesario para que funcione, funciona;
Código Javascript:
Ver original
  1. $(document).ready(function() {
  2.  
  3.         $("#salida_factprint").click(function(e) {
  4.           e.preventDefault(); // necesario
  5.           var id_aviso = document.forms['form2'].elements['id_aviso'];
  6.  
  7.           if (window.XMLHttpRequest) {
  8.             var xmlhttp = new XMLHttpRequest();
  9.           } else {
  10.             //xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  11.             alert('fallo xmlhttp');
  12.           }
  13.           xmlhttp.open("GET", "proc3.php?id_aviso=" + id_aviso.value, false);
  14.           xmlhttp.send();
  15.           /**
  16.            * Código en proc3.php: var_dump($_GET);
  17.            */
  18.           $('#test').html(id_aviso.value);
  19.  
  20.           if (xmlhttp.readyState === 4 && xmlhttp.status === 200) {
  21.             //var xml = xmlhttp.responseXML;
  22.             var xml = xmlhttp.responseText;
  23.             $('#test').html(xml);
  24.             /**
  25.              * Hasta aquí
  26.              * Rta: array(1) { ["id_aviso"]=> string(2) "10" }
  27.              */
  28.           }
  29.         });
  30.       });
Código HTML:
Ver original
  1. <form id="form2" name="form2">
  2.       <input type="text" id="id_aviso" value="10" />
  3.       <button id="salida_factprint">Boton</button>
  4.     </form>
  5.     <div id="test"></div>