Foros del Web » Programando para Internet » Javascript » Frameworks JS »

Error de lectura XML: no se encuentra elemento Ubicación: moz-nullprincipal

Estas en el tema de Error de lectura XML: no se encuentra elemento Ubicación: moz-nullprincipal en el foro de Frameworks JS en Foros del Web. Hola que tal ..estoy haciendo unas pruebas con un formulario en ajax y no recibo los datos en xml por un error de lectura...lo curioso ...
  #1 (permalink)  
Antiguo 05/08/2011, 14:52
 
Fecha de Ingreso: enero-2010
Mensajes: 31
Antigüedad: 14 años, 2 meses
Puntos: 0
Exclamación Error de lectura XML: no se encuentra elemento Ubicación: moz-nullprincipal

Hola que tal ..estoy haciendo unas pruebas con un formulario en ajax y no recibo los datos en xml por un error de lectura...lo curioso del caso es que solo uno un archivo .html y un .js ..
este es el codigo html
Código HTML:
Ver original
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2.            "http://www.w3.org/TR/html4/strict.dtd">
  3.     <script type="text/javascript" src="js/hack2.js"></script>
  4.     <meta http-equiv="content-type" content="text/html; charset=utf-8" />
  5.     <title>Send a data tidbit</title>
  6. </head>
  7. <h3>A Few Facts About Yourself...</h3>
  8. <form action="javascript:void%200" onsubmit="sendData(  );return false;">
  9.     <p>First name: <input type="text" name="firstname" size="20"> </p>
  10.     <p>Last name: <input type="text" name="lastname" size="20"> </p>
  11.     <p>Gender: <input type="text" name="gender" size="2"> </p>
  12.     <p>Country of origin: <input type="text" name="country" size="20"> </p>
  13.     <p><button type="submit">Send Data</button></p>
  14. </form>
  15. </body>
  16. </html>


y este el .js

Código Javascript:
Ver original
  1. var request;
  2.         var queryString;   //will hold the POSTed data
  3.  
  4.         function sendData(){
  5.             setQueryString();
  6.             var url="http://www.parkerriver.com/s/sender";
  7.             httpRequest("POST",url,true);
  8.         }
  9.  
  10. //event handler for XMLHttpRequest
  11.         function handleCheck(){
  12.             if(request.readyState == 4){
  13.                 if(request.status == 200){
  14.                     alert(request.responseText);
  15.                 } else {
  16.                     alert("A problem occurred with communicating between the XMLHttpRequest object and the server program.");
  17.                 }
  18.             }//end outer if
  19.  
  20.         }
  21.  
  22. /* Initialize a Request object that is already constructed */
  23.         function initReq(reqType,url,bool){
  24.             /* Specify the function that will handle the HTTP response */
  25.             request.onreadystatechange=handleCheck;
  26.             request.open(reqType,url,bool);
  27.             request.setRequestHeader("Content-Type",
  28.                     "application/x-www-form-urlencoded; charset=UTF-8");
  29.             request.send(queryString);
  30.         }
  31.  
  32. /* Wrapper function for constructing a Request object.
  33.  Parameters:
  34.   reqType: The HTTP request type such as GET or POST.
  35.   url: The URL of the server program.
  36.   asynch: Whether to send the request asynchronously or not. */
  37.         function httpRequest(reqType,url,asynch){
  38.             //Mozilla-based browsers
  39.             if(window.XMLHttpRequest){
  40.                 request = new XMLHttpRequest();
  41.             } else if (window.ActiveXObject){
  42.                 request=new ActiveXObject("Msxml2.XMLHTTP");
  43.                 if (! request){
  44.                     request=new ActiveXObject("Microsoft.XMLHTTP");
  45.                 }
  46.              }
  47.             //the request could still be null if neither ActiveXObject
  48.             //initializations succeeded
  49.             if(request){
  50.                initReq(reqType,url,asynch);
  51.             }  else {
  52.                 alert("Your browser does not permit the use of all "+
  53.                 "of this application's features!");}
  54.         }
  55. function setQueryString(){
  56.     queryString="";
  57.     var frm = document.forms[0];
  58.     var numberElements =  frm.elements.length;
  59.     for(var i = 0; i < numberElements; i++)  {
  60.             if(i < numberElements-1)  {
  61.                 queryString += frm.elements[i].name+"="+
  62.                                encodeURIComponent(frm.elements[i].value)+"&";
  63.             } else {
  64.                 queryString += frm.elements[i].name+"="+
  65.                                encodeURIComponent(frm.elements[i].value);
  66.             }
  67.  
  68.     }
  69. }

parece que este error tiene que ver con el servidor...pero no se como solucionarlo..
el codigo lo he sacado de esta ruta http://www.parkerriver.com/ajaxhacks/ajax_hack2.html ..el cual si funciona...pero por que a mi no ???????
siempre recibo este alerta: A problem occurred with communicating between the XMLHttpRequest object and the server program.

y navegando con el firebug me encuentro Error de lectura XML: no se encuentra elemento Ubicación: moz-nullprincipal:{47e1760e-116d-7447-b59f-1571b45c0eb2} Número de línea 1, columna 1:

^


Alguna solucion???
  #2 (permalink)  
Antiguo 06/09/2011, 17:23
Avatar de Danielfuzz  
Fecha de Ingreso: septiembre-2007
Mensajes: 111
Antigüedad: 16 años, 6 meses
Puntos: 18
Respuesta: Error de lectura XML: no se encuentra elemento Ubicación: moz-nullprincipa

Hola ricci00, yo tuve el mismo mensaje de error al tratar de cargar un xml vía ajax con jquery. Averiguando descubrí q esto pasa cuando haces la petición a otro dominio, osea otro dominio q no sea el tuyo.

En mi caso se presentó sólo cuando el usuario ingresaba al sitio con www. por delante, ya q el navegador detectaba a www.misitio.com y misitio.com como dos sitios diferentes, así que tuve que usar document.domain para evitar este problema.

en tu caso parece que estás haciendo la petición a otro dominio, deberías buscar si existe alguna manera de hacer la petición AJAX a otro dominio.

Espero haberte ayudado

Saludos.

Etiquetas: ajax, encuentra, lectura, post, xml, formulario
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 06:42.