Ahora me salta este problema con AJAX: Tengo un formulario que trabaja con una validación en AJAX. El código HTML del formulario tiene esta forma:
Código HTML:
 <form id="frmnuevo" action="" method="post" onsubmit="procesarForm(); return false"> <input type="text" id="nombre" name="nombre" /> <input type="text" id="email" name="email" /> <input type="submit" id="btnaceptar" name="btnaceptar" value="Aceptar" /> </form>
Código:
  
donde la función ejecutar es la típica función que crea el objeto XmlHttpRequest y lo prepara para su uso. Su implementación es:function procesarForm()
{
    var nombre = document.getElementById('nombre').value;
    var email = document.getElementById('email').value;
    ejecutar("scripts/crear.php?nombre=" + nombre + "&email=" + email, procesarRespuesta);
}
Código:
  
Bueno, en realidad el formulario tiene bastante más campos, y por tanto la función procesarForm es bastante más grande; pero en ambos casos la estructura es la que mostré en este miniejemplo (no puedo poner el código original porque es muy grande y porque en mi trabajo no me permiten publicarlo).// Guarda la referencia al objeto XmlHttpRequest
var xmlHttp;
// Recupera el objeto  XmlHttpRequest
function createXmlHttpRequestObject()
{
	// will store the reference to the XMLHttpRequest object
	var xmlHttp;
	// if running Internet Explorer
	if(window.ActiveXObject)
	{
		try
		{
			xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch (e)
		{
			xmlHttp = false;
		}
	}
	// if running Mozilla or other browsers
	else
	{
		try
		{
			xmlHttp = new XMLHttpRequest();
		}
		catch (e)
		{
			xmlHttp = false;
		}
	}
	// return the created object or display an error message
	if (!xmlHttp)
		alert("¡Error al crear el objeto XMLHttpRequest!");
	else
		return xmlHttp;
}
// make asynchronous HTTP request using the XMLHttpRequest object
function ejecutar(url, callback)
{
	xmlHttp = createXmlHttpRequestObject();
	// proceed only if the xmlHttp object isn't busy
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	{
		// execute the quickstart.php page from the server
		xmlHttp.open("GET", url, true);
		// define the method to handle server responses
		xmlHttp.onreadystatechange = callback;
		// make the server request
		xmlHttp.send(null);
	}
	else
		// if the connection is busy, try again after one second
		setTimeout('ejecutar()', 1000);
}
En fin, a lo que iba... He probado este código en 3 navegadores:
- Internet Explorer 7
 - Mozilla Firefox 2.0.0.12
 - Opera 9.2
 
En los 2 últimos el código funciona bien; pero cuando lo pruebo en Internet Explorer me salta este mensaje: The system cannot locate the resource specified
Instalé MS Script Debugger y cuando pruebo nuevamente mi código el depurador se detiene en la función ejecutar() que puse arriba, concretamente en esta línea:
Código:
  
No entiendo lo que sucede, ¿alguien me lo puede explicar? ¿Cómo puedo solucionarlo? function ejecutar(url, callback)
{
	xmlHttp = createXmlHttpRequestObject();
	if (xmlHttp.readyState == 4 || xmlHttp.readyState == 0)
	{
		xmlHttp.open("GET", url, true);
		xmlHttp.onreadystatechange = callback;
		xmlHttp.send(null);  // <---------------- AQUI SE DETIENE EL SCRIPT
	}
	else
		setTimeout('ejecutar()', 1000);
}
 
 
