Ver Mensaje Individual
  #1 (permalink)  
Antiguo 03/02/2012, 05:33
daberyah
 
Fecha de Ingreso: febrero-2012
Mensajes: 2
Antigüedad: 12 años, 3 meses
Puntos: 0
Pregunta La ejecución de un script con ajax se bloquea en IE

Tan rícamente ensayando con Firefox y cuando se ejecuta con IE se bloquea, teniendo que reiniciar este navegador.

Se trata de un script que se dispara con el evento onchange de un select que contiene las provincias de España:

onchange="CargaLocalidades(this.value,'selectLocal idad');"

La función trata de cargar en el siguente select los municipios según sea la selección de la provincia en el select inicial.

El 2ª parámetro es el id del select donde se cargarán las localidades de la provincia elegida

Los datos de los municipios los extraigo de la respuesta que entrega la función ajax, a la que se llama con otra función copiada de estos mismos foros:

Código PHP:
function XMLHttp(){
        var 
Object;
        if (
typeof XMLHttpRequest == "undefined" ) {
            if(
navigator.userAgent.indexOf("MSIE 5") >= 0) { 
                
Object= new ActiveXObject("Microsoft.XMLHTTP");
            } else { 
                
Object=new ActiveXObject("Msxml2.XMLHTTP");
            }
        } else { 
            
Object=new XMLHttpRequest();
        }
        return 
Object;
    }
    
    function 
CargaLocalidades(valor,obj){
        var 
ajax2 XMLHttp();
        var 
provincia valor;
        var 
oCntrl document.getElementById(obj);
        
oCntrl.options.length 0;
        var 
selOpcion = new Option("BUSCANDO...""0");
        var 
iPos oCntrl.options.length;
        
oCntrl.options[iPos] = selOpcion;
        
ajax2.open("GET","ajax/charge_loc.php?prov=" provinciatrue);
        
ajax2.onreadystatechange=function(){
            if(
ajax2.readyState==4) {
                var 
respuesta=ajax2.responseText;
                var 
pos respuesta.indexOf("#");
                var 
ind respuesta.indexOf("|");
                var 
1;
                
oCntrl.options.length 0;
                var 
selOpcion = new Option("<Seleccione Localidad>""0");
                var 
iPos oCntrl.options.length;
                
oCntrl.options[iPos] = selOpcion;
                while(
pos!=-1){
                    var 
municipio;
                    
municipio respuesta.substring(0,pos);
                    
indice respuesta.substring(pos+1,ind);
                    
selOpcion = new Option(municipio.toUpperCase(), indice);
                    
iPos oCntrl.options.length;
                    
oCntrl.options[iPos] = selOpcion;
                    
i++;
                    var 
auxiliar1 respuesta.substring(ind+1);
                    
respuesta auxiliar1;
                    
pos respuesta.indexOf("#");
                    
ind respuesta.indexOf("|");
                }
            }
        }
        
ajax2.send(null);
    } 
La función ajax, para distinguir el identificador del nombre del municipio, la devuelve del siguente modo:

.....NOMBRE_MUNICIPIO#ID_MUNICIPIO|......

Es decir, usando los carácteres especiales # y | para separar un campo de otro.

Alguien puede arrojarme algo de luz a lo que está pasando.

Gracias