Ver Mensaje Individual
  #12 (permalink)  
Antiguo 01/02/2015, 05:48
Avatar de alexisverano
alexisverano
 
Fecha de Ingreso: septiembre-2008
Ubicación: La Habana.Cuba
Mensajes: 298
Antigüedad: 15 años, 7 meses
Puntos: 36
Respuesta: Cargar nuevo dato en combo sin recargar la pagina

Fichero ajax.js

Código Javascript:
Ver original
  1. //========================
  2. //CREACION DEL OBJETO AJAX
  3. //========================
  4. function objetoAjax(){
  5.     var xmlhttp=false;
  6.     try {
  7.         xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  8.     } catch (e) {
  9.         try {
  10.            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  11.         } catch (E) {
  12.             xmlhttp = false;
  13.         }
  14.     }
  15.  
  16.     if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  17.         xmlhttp = new XMLHttpRequest();
  18.     }
  19.     return xmlhttp;
  20. }
  21.  
  22.  
  23. //==========================================================
  24. function enviar_personas(){
  25.     divResultado = document.getElementById('resultados');
  26.     nombre = document.getElementById('obj_text').value;
  27.  
  28.     ajax=objetoAjax();
  29.     ajax.open("POST", "accion.php");
  30.     ajax.onreadystatechange=function() {
  31.         if (ajax.readyState==4) {
  32.             divResultado.innerHTML = ajax.responseText
  33.         }
  34.     }
  35.     ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
  36.     ajax.send("nombre="+nombre)
  37. }