Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [advAjax] problem z obj.responseXML
miedzna
post 20.02.2007, 11:23:15
Post #1





Grupa: Zarejestrowani
Postów: 401
Pomógł: 1
Dołączył: 10.03.2004
Skąd: Warszawa

Ostrzeżenie: (0%)
-----


Witam,
mam plik php wynik.php, który robi XML:
  1. if (isset($_GET['dane'])){
  2.  
  3. header('Content-Type: text/xml');
  4.  
  5. $xml = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>';
  6. $xml .= '<dane>';
  7. $xml .= '<nazwa>' . $_GET["dane"] . '</nazwa>';
  8. $xml .= '<link>' . $_GET["link"] . '</link>';
  9. $xml .= '</dane>';
  10.  
  11. print $xml;
  12.  
  13. }


oraz plik js, który miałby za zadanie odczytać tego XMLa:
  1. var blnAjaxDebug = false;
  2.  
  3. function ajaxget( region, ResponseId )
  4. {
  5. if( ResponseId == undefined )
  6. {
  7. ResponseId = 'wynik';
  8. }
  9.  
  10. region = "wynik.php?" + region;
  11. advAJAX.get({
  12. url: region,
  13. onLoading : function() {
  14. contentHTML = document.getElementById( ResponseId ).innerHTML;
  15. document.getElementById( ResponseId ).innerHTML = document.getElementById( 'ladowanie' ).innerHTML;
  16. },
  17. onSuccess : function(obj) {
  18.  
  19. document.getElementById( ResponseId ).innerHTML = obj.responseXML;
  20. ajaxDebug( obj.responseXML );
  21.  
  22.  
  23. },
  24. onError : function(obj) {
  25. document.getElementById( ResponseId ).innerHTML = contentHTML;
  26. window.alert('Wystąpił nieoczekiwany błąd. Powtórz operację.');
  27. }
  28. });
  29. }
  30.  
  31. function ajaxDebug( HTMLtext )
  32. {
  33. if ( blnAjaxDebug == true )
  34. {
  35. 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");
  36. okno.document.write('<HTML>');
  37. okno.document.write('<TITLE>DEBUG AJAX</TITLE>');
  38. okno.document.write('<HEAD>');
  39. okno.document.write('<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />');
  40. okno.document.write('</HEAD>');
  41. okno.document.write('<BODY>');
  42. okno.document.write(HTMLtext);
  43. okno.document.write('</BODY>');
  44. okno.document.write('</HTML>');
  45. okno.document.close();
  46. }
  47. }


chodzi o kawałek kodu:
  1. onSuccess : function(obj) {
  2.  
  3. document.getElementById( ResponseId ).innerHTML = obj.responseXML;
  4. ajaxDebug( obj.responseXML );
  5.  
  6.  
  7. },


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ść.
Go to the top of the page
+Quote Post
nospor
post 20.02.2007, 11:35:17
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




responseXML zwraca obiekt XML. Jak chcesz po XML latac to poczytaj o DOM w js. A jak chcesz zobaczyc text tego xmla to responseText


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 29.06.2025 - 17:08