This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I never had luck in getting responseXML from Ajax call. I have been following each and every post in this forum regrading the Ajax and I myself had partcipated in few. I never had/have issue in getting reposeText. It works perfect. But I really really want to get my result as an xml now. I know the basic thumb rule for reposeXML which says unless the xml is perfectly formatted, it will return blank.
I am pretty confident that my final xml is perfectly foramatted. <?xml version="1.0" ?> <entry>2006</entry> <entry>Please Pick One</entry>
I recently saw RoshiniG Gopals post and Merill's and other peoples valuable input on that topic . Merill also suggested the same for me long back.
I am positng my code. Please let me know where it is wrong. alerting responseXML gives me null and so the subsequent alert statements. In one of the forum someone suggested that ignore whether or not alert of responseXML gives null or not and simply call getElementsByTagName. I tried that also but no luck. alert('Value of XRows:'+xRows) gives me nothing
Please advice me where I am wrong.
Added code UDD for readability [ September 22, 2006: Message edited by: Merrill Higginson ]
As I look for problems in your code, nothing jumps out at me. Please look at the "Hello World" AJAX example that appears as the last post in this linkTry coding it and running it. I'd be interested to know if you get a responseXML when you run this example. Also, which browser are you using? I tried this example on both IE V6, and Firefox.
Something like <?xml version="1.0" ?> <entries> <entry>asdasd</entry> <entry>asdasd</entry> <entry>asdasd</entry> </entries>
would work properly.
Always test your xml in either Internet explorer or Firefox. It helps [ ]
Joined: Oct 06, 2005
Following are the observations that I noticed regarding reponseXML from Ajax call
1. When I added root element to the code that I shown above as per Anay Nayak's suggestion, it worked fine. So my final xml is <?xml version="1.0" ?> <entries> <entry>2006</entry> <entry>Please Pick One</entry> </entries>
2. Merill's example code shown at this link http://www.coderanch.com/t/53656/Struts/Ajax-struts-integration worked fine for me. But if you notice, he is not adding <?xml version="1.0" ?> . I tried adding/removing this to final xml response and does not make any difference. I thought it is mandatory to have <?xml version="1.0" ?> to get xml response, is this correct ?(???.....)
I then changed like this to add root element out.write("<entries>"); out.write("<hello>hello world1</hello>"); out.write("<hello>hello world2</hello>"); out.write("</entries>"); It started to work fine now.
Please confirm my observations/questions. Thank you all for helping me to fix my problem.