alin19 Posted August 29, 2008 Share Posted August 29, 2008 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); } } } Quote Link to comment Share on other sites More sharing options...
Ken2k7 Posted August 30, 2008 Share Posted August 30, 2008 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. Quote Link to comment Share on other sites More sharing options...
crocodilu2008 Posted September 4, 2008 Share Posted September 4, 2008 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 Quote Link to comment Share on other sites More sharing options...
corbin Posted September 4, 2008 Share Posted September 4, 2008 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. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.