Jump to content

responseXML faild


alin19

Recommended Posts

it does'n alert anything where is the red part, so i think that it is an error in the response

 

please help

 

function verificaNume(nume,raspuns) {

if (raspuns !='') {

mesaj = document.getElementById('existaEroare');

if (raspuns == 1)

 

mesaj.className='eroare';

 

else

 

mesaj.className='ascuns';

}

else

{

 

incarcaXML('verifica.php?nume=' + nume);

 

}

}

 

var cerere;

 

function incarcaXML(url) {

if (window.XMLHttpRequest) {

 

cerere= new XMLHttpRequest ();

 

cerere.onreadystatechange = trateazaCererea;

cerere.open("GET", url, true);

cerere.send(null);

}

}

 

function trateazaCererea () {

if (cerere.readyState == 4){

if (cerere.status==200) {

raspuns= cerere.responseXML.documentElement;

alert (raspuns);

var n = response.getElementsByTagName('metoda')[0].firstChild.nodeValue;

    alert(n);

 

metoda=raspuns.getElementsByTagName('metoda')[0].firstChild.data;

    alert(metoda);

 

rezultat= raspuns.getElementsByTagName('rezultat')[0].firstChild.data;

 

eval ( metoda + '(\'\', rezultat)');

}

else {

alert ("a aparut o problema" + cerere.statusText);

}

}

}

 

 

Link to comment
Share on other sites

Please


your code.

 

To use the .responseXML method, you need to send a header telling the data you're sending is XML, otherwise, your browser will treat is as regular text. Also, that method ONLY works in Firefox right now. IE 7 and lower will not work. I do not recommend it.

Link to comment
Share on other sites

 

 

Assure you have correct header type in your <<verifica.php?nume=' + nume>> file if is dynamic generated. Firefox return error in xml interpretation /parsing

 

<?header('Content-type: application/xml; charset="utf-8"',true);?>

<myxml><root>Hello world!</root></myxml>

 

 

 

 

A good tutorial for how to create a ajax request is

http://www.phpfreaks.com/forums/index.php/topic,115581.0.html

 

 

About diferences between Browsers  you must read Migrate apps from Internet Explorer to Mozilla http://navioo.com/ajax/diferences.php

Link to comment
Share on other sites

The problem here appears to be variable scope to me.  cerere holds the class so this is a little counter-intuitive.  You would think that a method of the class that is held in a variable would have access to that variable, but I'm pretty sure it doesn't work that way.

 

 

Look into variable scope.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.