[ iizuzetan @ 14.07.2009. 17:22 ] @
Hocu da vrednost iz XMLHttpRequest objekta prebacim u JavaScript promenjljivu ali nikako da uspem pa zato ako bi mogo neko da mi pomogne. Na primer sledeci kod radi: Code: <html><head><title>Ajax primer sa XML ispisom</title> <script type="text/javascript"> function ajaxFunction() { if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest();} else if (window.ActiveXObject) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");} else { alert("Your browser does not support XMLHTTP!"); } function xmlhttp.onreadystatechange(){ if(xmlhttp.readyState==4) { var vremeTekuce = xmlhttp.responseXML.getElementsByTagName("vremesada")[0]; document.getElementById('vremePrikaz').innerHTML = vremeTekuce.childNodes[0].nodeValue; } } xmlhttp.open("GET","XMLpisiVreme.php",true); xmlhttp.send(null); } </script> </head><body onLoad="ajaxFunction()"> <div id="vremePrikaz"></div> </body></html> A sledeci kod ne radi: Code: <html><head><title>Ajax primer sa XML ispisom</title> <script type="text/javascript"> function ajaxFunction() { if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest();} else if (window.ActiveXObject) { xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");} else { alert("Your browser does not support XMLHTTP!"); } function xmlhttp.onreadystatechange(){ if(xmlhttp.readyState==4) { var vremeTekuce = xmlhttp.responseXML.getElementsByTagName("vremesada")[0]; a = vremeTekuce.childNodes[0].nodeValue; } } xmlhttp.open("GET","XMLpisiVreme.php",true); xmlhttp.send(null); return a } </script> </head><body> <script> document.write (ajaxFunction()); </script> </body></html> Gde je greska i kako da vrednost iz XMLHttpRequest objekta prebacim u JavaScript promenjljivu na primer var a a ne tamo u vrednost nekog elementa forme ili u vrednost nekog elementa id?????? Pomagajte ako znate :) |