mam plik php wynik.php, który robi XML:
if (isset($_GET['dane'])){ header('Content-Type: text/xml'); $xml = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>'; $xml .= '<dane>'; $xml .= '<nazwa>' . $_GET["dane"] . '</nazwa>'; $xml .= '<link>' . $_GET["link"] . '</link>'; $xml .= '</dane>'; print $xml; }
oraz plik js, który miałby za zadanie odczytać tego XMLa:
var blnAjaxDebug = false; function ajaxget( region, ResponseId ) { if( ResponseId == undefined ) { ResponseId = 'wynik'; } region = "wynik.php?" + region; advAJAX.get({ url: region, onLoading : function() { contentHTML = document.getElementById( ResponseId ).innerHTML; document.getElementById( ResponseId ).innerHTML = document.getElementById( 'ladowanie' ).innerHTML; }, onSuccess : function(obj) { document.getElementById( ResponseId ).innerHTML = obj.responseXML; ajaxDebug( obj.responseXML ); }, onError : function(obj) { document.getElementById( ResponseId ).innerHTML = contentHTML; window.alert('Wystąpił nieoczekiwany błąd. Powtórz operację.'); } }); } function ajaxDebug( HTMLtext ) { if ( blnAjaxDebug == true ) { okno = window.open("","ajaxDebug","width=800,height=600,top=10,left=20,resizable=no,scrollbars=no,menubar=no,t
oolbar=no,status=no,location=no,status=no"); okno.document.write('<HTML>'); okno.document.write('<HEAD>'); okno.document.write('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />'); okno.document.write('</HEAD>'); okno.document.write('<BODY>'); okno.document.write(HTMLtext); okno.document.write('</BODY>'); okno.document.write('</HTML>'); okno.document.close(); } }
chodzi o kawałek kodu:
onSuccess : function(obj) { document.getElementById( ResponseId ).innerHTML = obj.responseXML; ajaxDebug( obj.responseXML ); },
jak wywołuję tę funkcję, to zwraca mi [object] i nic więcej, nie wiem jak mam przejechać się po wygenerowanym XMLu, żeby wyświetlić jego zawartość.