Ver Mensaje Individual
  #7 (permalink)  
Antiguo 09/12/2013, 11:25
Avatar de Dalam
Dalam
 
Fecha de Ingreso: septiembre-2010
Mensajes: 409
Antigüedad: 14 años, 4 meses
Puntos: 56
Respuesta: Problema con AJAX

xSkArx con los cambios que te dijo mortiprogramador tendria que redirigirte el formulario, para evitar eso tienes dos opciones.

1- Utilizando el preventDefault para que el formulario no sea enviado.
2- Quitando las etiquetas del form, puesto que no es utilizado.

La segunda opcion es la mas acertada en este caso, por que no utilizas el formulario para ser enviado, y si el cliente no tiene javascript activado, no sera redireccionado a ninguna pagina y todo se quedara como esta.

Te aconsejo que separes el objeto xmlhttp de el resto de funciones para que puedas usar la funcion si tienes mas de una peticion a paginas distintas.
Por ejemplo de esta forma:
Código Javascript:
Ver original
  1. function objetus(file){
  2.  
  3.     xmlhttp=false;
  4.     this.AjaxFailedAlert = "Su navegador no soporta las funcionalidades de este sitio y podria experimentarlo de forma diferente a la que fue pensada. Por favor habilite javascript en su navegador para verlo normalmente.\n";
  5.     this.requestFile = file;
  6.     this.encodeURIString = true;
  7.     this.execute = false;
  8.     if (window.XMLHttpRequest){
  9.         this.xmlhttp = new XMLHttpRequest();
  10.         if (this.xmlhttp.overrideMimeType){
  11.             this.xmlhttp.overrideMimeType('text/xml');
  12.         }
  13.     }else if (window.ActiveXObject){ // IE
  14.         try{
  15.             this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  16.         }catch (e){
  17.             try{
  18.                 this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  19.             }catch (e){
  20.                 this.xmlhttp = null;
  21.             }
  22.         }
  23.         if (!this.xmlhttp && typeof XMLHttpRequest!='undefined'){
  24.             this.xmlhttp = new XMLHttpRequest();
  25.             if (!this.xmlhttp){
  26.                 this.failed = true;
  27.             }
  28.         }
  29.     }
  30.     return this.xmlhttp ;
  31. }