Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » AJAX ... Javascript - XMLHttp Objects - Getting the XML responses...
Closed Thread
Old 06-14-2007, 01:59 PM   #1 (permalink)
 
Monster Techie

Join Date: May 2004

Location: Tucson, AZ, USA

Posts: 1,183

Vormund

Send a message via AIM to Vormund Send a message via MSN to Vormund Send a message via Yahoo to Vormund
Default AJAX ... Javascript - XMLHttp Objects - Getting the XML responses...

Has anyone dealt with this? I'm making a simple "shout-out" type form on my website, and so far have it successfully posting / querying, but getting the results is another story.

This is an example of what is returned to the XML HTTP Object (XHO):
Code:
<xmlresponse>
  <msg>sdfsadf</msg>
  <msg>hmm</msg>
  <msg>sdfsdf</msg>
  <msg>hmm?</msg>
  <msg>blarg</msg>
</xmlresponse>
Using this on the response:
Code:
document.getElementById( "test" ).innerHTML = XHO.responseText;
My <div id="test"></div> displays the output like the above, so I know it's working...response-wise. But the nice thing about this is the XML parser that should make it easy. As I understand it, this:
Code:
alert( XHO.responseXML.getElementsByTagName( 'msg' )[0].data );
Should display "sdfsadf" since it's the first element...but if I do anything with
Code:
XHO.responseXML.getElementsByTagName( 'msg' )[0].data
as a part of it, the Javascript seemingly terminates / or whatever it does it never finishes.

Any ideas?
__________________
Vormund is offline  
Old 06-15-2007, 12:49 PM   #2 (permalink)
 
Monster Techie

Join Date: May 2004

Location: Tucson, AZ, USA

Posts: 1,183

Vormund

Send a message via AIM to Vormund Send a message via MSN to Vormund Send a message via Yahoo to Vormund
Default Re: AJAX ... Javascript - XMLHttp Objects - Getting the XML responses...

All that time wasted...and the only problem was I needed to set the header to text/xml, since I was using PHP to generate it. :eek:
__________________
Vormund is offline  
Old 06-17-2007, 04:02 PM   #3 (permalink)
 
Banned

Join Date: Oct 2006

Posts: 81

williwaw

Default Re: AJAX ... Javascript - XMLHttp Objects - Getting the XML responses...

**SRY, Off-Topic**

I am interested in a full tutorial and code source for your "shout out" if you have time. Or if you can post some links that you found most helpful, that would be great.

Cheers,
Williwaw

williwaw is offline  
Old 06-17-2007, 04:18 PM   #4 (permalink)
Nick's Avatar
 
Courtesy of Mak.

Join Date: Feb 2007

Location: Chichester, England

Posts: 3,998

Nick is on a distinguished road

Send a message via MSN to Nick
Default Re: AJAX ... Javascript - XMLHttp Objects - Getting the XML responses...

ajax is a dutch football club
__________________
Every time I get Rep, I die inside.

Cisco Cert.
Nick is offline  
Old 06-18-2007, 01:21 AM   #5 (permalink)
 
Monster Techie

Join Date: May 2004

Location: Tucson, AZ, USA

Posts: 1,183

Vormund

Send a message via AIM to Vormund Send a message via MSN to Vormund Send a message via Yahoo to Vormund
Default Re: AJAX ... Javascript - XMLHttp Objects - Getting the XML responses...

More then happy to, but...being the AJAX that it is, you can see my "shout out" thing at my website, it uses Javascript to do so...so it's 99% visible to you now. (Just view the page source, and look for the <script type="text/javascript"> - it's all in there. I just have five spanning fields, make a call to my server-side script, and retrieve messages if there are new ones since the last update, based on a timestamp created on the initial call for messages.

It's not quite secure yet, but semi-close...smart punks can still abuse it, but I worry about the details after the gist of it is working (as it's just the basic post/get calls that can be tampered with).

I plan on adding a few obvious things in the near future - spam/time catching, auto ip-banning for doing such a thing (at least temp), filters for foolios (I have previous project for this), and more importantly, probably adding unlimited message history, as five is a 'lil short.

Anyhow if you have any specific questions, feel free to ask...and I can attempt answering them. I will probably be writing up a guide on it after I'm complete, as it still has a ways to go, but it's a working process.

Quote:
Originally Posted by nickm926 View Post
ajax is a dutch football club
Huh? I sense jealousy here. It's ok, not all people are cool enough to get down with AJAX.
__________________
Vormund is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On