![]() |
![]() |
![]()
Post
#1
|
|
![]() Grupa: Zarejestrowani Postów: 426 Pomógł: 1 Dołączył: 2.10.2005 Ostrzeżenie: (0%) ![]() ![]() |
Witam
Mam pewien problem przy używaniu ResponseXML w prototype:
No i błąd występuje przy odbieraniu XML w : response = Request.responseXML; Cały czas jest pokazany loader, że trwa zapisywanie komentarza (linie poniżej wogle nie są wykonywane), gdy zmienie response = Request.responseXML; na response = Request.responseText; i sprawdze co zwraca skrypt to otrzymuje xml wygenetowany przez XMLwriter:
Pozdrawiam Ten post edytował Apo 27.01.2007, 18:03:36 |
|
|
![]() |
![]()
Post
#2
|
|
![]() Grupa: Zarejestrowani Postów: 82 Pomógł: 3 Dołączył: 15.01.2007 Ostrzeżenie: (10%) ![]() ![]() |
Wydaje sie ze po prostu zle parsujesz xmla
Przykldadowe poprawne parsowanie:
Najlatwiej uzyc getElementsByTagName do uzyskania dostepu do wezlow. Ten post edytował defrag 28.01.2007, 10:30:53 |
|
|
![]()
Post
#3
|
|
![]() Grupa: Zarejestrowani Postów: 426 Pomógł: 1 Dołączył: 2.10.2005 Ostrzeżenie: (0%) ![]() ![]() |
Defrag tylko mi to co jest poniżej tego:
Kod wogle sie nie wykonuje, nawet jak jakis alert wstawie za tym, dodam że xml generuje w taki sposób:
|
|
|
![]()
Post
#4
|
|
![]() Grupa: Zarejestrowani Postów: 548 Pomógł: 2 Dołączył: 19.07.2003 Ostrzeżenie: (0%) ![]() ![]() |
witam
zmień Content-type na application/xml pozdrawiam Ten post edytował orson 28.01.2007, 12:33:56 -------------------- Computer games don't affect kids; I mean if <span style="font-weight: bold;">Pac Man</span> affected us as kids,we would all be running around in darkened rooms, munching magic pills and listening to repetitive electronic music.
|
|
|
![]()
Post
#5
|
|
![]() Grupa: Zarejestrowani Postów: 426 Pomógł: 1 Dołączył: 2.10.2005 Ostrzeżenie: (0%) ![]() ![]() |
Heh dalej to samo, nic poniżej lini response = Request.responseXML; sie nie wykonuje i cały czas jest pokazany Loader ;/
|
|
|
![]()
Post
#6
|
|
![]() Grupa: Zarejestrowani Postów: 160 Pomógł: 4 Dołączył: 22.04.2006 Skąd: Kraków Ostrzeżenie: (0%) ![]() ![]() |
skomentuj error = response.getAttribute('error');
Bo wydaje mi się że za każdym razem musi być tag <error> -------------------- |
|
|
![]()
Post
#7
|
|
![]() Grupa: Zarejestrowani Postów: 426 Pomógł: 1 Dołączył: 2.10.2005 Ostrzeżenie: (0%) ![]() ![]() |
Tez nic, i tak pisałem ze reszta sie nie wykonuje ;/
Ten post edytował Apo 28.01.2007, 20:40:14 |
|
|
![]()
Post
#8
|
|
Grupa: Zarejestrowani Postów: 71 Pomógł: 2 Dołączył: 6.07.2005 Skąd: Legnica Ostrzeżenie: (0%) ![]() ![]() |
Po pierwsze, to ten XML nie jest poprawny. Dokument XML może mieć tylko jeden root element, u ciebie jest ich więcej.
Powinno być mniej więcej tak:
Generowane np. tak:
Element error dodawaj zawsze, a wartości możesz pobierać np. tak: Kod var root = $A(Request.responseXML.getElementsByTagName('response'))[0]; var error = root.firstChild; var nick = error.nextSibling; var email = nick.nextSibling; var www = email.nextSibling; var content = www.nextSibling; if(error.firstChild.nodeValue == 1) alert('Wystąpił błąd. Komentarz nie został dodany'); else $('add_comment').innerHTML = content.firstChild.nodeValue; Jeśli masz stałą kolejność elementów, lub Kod var error = $A(root.getElementsByTagName('error'))[0];
var nick = $A(root.getElementsByTagName('nick'))[0]; var email = $A(root.getElementsByTagName('email'))[0]; var www = $A(root.getElementsByTagName('www'))[0]; var content = $A(root.getElementsByTagName('content'))[0]; -------------------- SithTemplate
|
|
|
![]() ![]() |
![]() |
Wersja Lo-Fi | Aktualny czas: 21.06.2025 - 19:52 |