[jQuery] [*Possible SPAM*] rewriting generic ajax jQuery style

[jQuery] [*Possible SPAM*] rewriting generic ajax jQuery style

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<META content="MSHTML 6.00.2900.3059" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=617181013-06032007><FONT face=Arial color=#0000ff
size=2>certainly:</FONT></SPAN></DIV>
<DIV><SPAN class=617181013-06032007><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=617181013-06032007>
<DIV class="netInfoResponseText netInfoText" selected="true"><PRE><?xml version="1.0" encoding="utf-8"?><catagories><item><item_id>659</item_id><item_name>3 Gal Beverage</PRE><PRE> Igloo Cooler</item_name></item><item><item_id>660</item_id><item_name>5 Gal Beverage Igloo Cooler</item_name</PRE><PRE>></item><item><item_id>661</item_id><item_name>10 Gal Beverage Igloo Cooler</item_name></item><item></PRE><PRE><item_id>662</item_id><item_name>3 Gal Iced Tea Dispenser</item_name></item><item><item_id>663</item_id</PRE><PRE>><item_name>120 Qt. Ice Sheet</item_name></item><item><item_id>664</item_id><item_name>Party Cooler<</PRE><PRE>/item_name></item><item><item_id>665</item_id><item_name>Keg Cooler</item_name></item></catagories></PRE><PRE><SPAN class=617181013-06032007>I'm sorry that's not indented for viewability.... I just copied it out of firebug.</SPAN></PRE><PRE><SPAN class=617181013-06032007>-Jim</SPAN></PRE></DIV></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> discuss-bounces@jquery.com
[mailto:discuss-bounces@jquery.com]<B>On Behalf Of </B>Jake
McGraw<BR><B>Sent:</B> Monday, March 05, 2007 5:07 PM<BR><B>To:</B> jQuery
Discussion.<BR><B>Subject:</B> [*Possible SPAM*] Re: [jQuery] rewriting
generic ajax jQuery style<BR><BR></FONT></DIV>Jim,  could you post a
version of the XML data you'd expect?<BR><BR>- jake<BR><BR>
<DIV><SPAN class=gmail_quote>On 3/5/07, <B class=gmail_sendername>Jim
Wharton</B> <<A href="mailto:jwharton@acpafl.org">jwharton@acpafl.org
</A>> wrote:</SPAN>
<BLOCKQUOTE class=gmail_quote
style="PADDING-LEFT: 1ex; MARGIN: 0pt 0pt 0pt 0.8ex; BORDER-LEFT: rgb(204,204,204) 1px solid">Hi,
I'm trying to change a bunch of handwritten Ajax stuff to use jQuery's
methods. (I figure, if I'm already including the jquery.js file, I may as
well use the heck out of it.)<BR><BR>My current code sends a request to a
php page and gets back an xml result I do the standard way of creating a
request object(try/catch for MSXML vs XHR)<BR><BR>here is the code to create
my request and callback:<BR><BR>var http =  createRequestObject();
//this just references that object I just created.<BR><BR>function ajax (
url, callback
)<BR>{<BR>        http.open ( 'get',
url, true );
<BR>        http.onreadystatechange
=
callback;<BR>        http.send(null);<BR>}<BR><BR>function
sendRequest() {<BR>        var url =
"getItems.php?cat_id=" +
idsource;<BR>        ajax( url,
handleInfo );<BR>}<BR><BR>my handleInfo function does a nice for loop based
on an array(object) and generates table html for each
"record":<BR><BR>function handleInfo()
{<BR>        if (http.readyState ==
1)
{<BR>                //document.getElementById("itemtable"
+idsource).innerHTML = '<h1>Loading...</h1>'
<BR>        }<BR>        if
(http.readyState == 4)
{<BR>                if
(http.status == 200)
{<BR>                                var
xmlDoc =
http.responseXML.documentElement;<BR>                                var
output;
<BR>                                output
= '<table><thead><tr><th>Items
Available</th></tr></thead><tbody>';<BR>                                //
Create table rows for each record
<BR>                                for
(var i=0; i < xmlDoc.childNodes.length;
i++)<BR>                                {<BR>                                        var
linkId = xmlDoc.getElementsByTagName('item_id').item(i).firstChild.data;
<BR>                                        output
+=
'<tr>';<BR>                                        output
+=
'<td>'+linkId;<BR>                                        output
+= '<td><a href=" itemdetail.php?item_id='+linkId+'"
>'+xmlDoc.getElementsByTagName('item_name').item(i).firstChild.data+'</a></td>';<BR>                                        output
+= '</tr>';
<BR>                                }<BR>                                        output
+=
'</tbody></table>';<BR>                                        document.getElementById("itemtable"
+idsource).innerHTML = output;
<BR>                }<BR>        }<BR>}<BR><BR>Ok,
fairly generic routine stuff. Only problem is, I can't bend my mind around
the way to do it in jQuery!!! I have started playing around with the .get
method:<BR><BR>$(document).ready(function() {
<BR>                $('#resultcontainer').accordion();<BR>                                $("dt").click(function(){<BR>                                        idsource
=
$(this).attr("id");<BR>                                        $.get("getItems.php",
{cat_id: idsource},
function(xml){<BR>                                                //build
a table from xml
results.<BR>                                                var
output = '<table><thead><tr><th>Items
Available</th></tr></thead><tbody>';
<BR>                                                var
xmlDoc =
xml.documentElement;<BR>                                                //create
rows for each
result.<BR>                                                for
(var i=0; i< xmlDoc.childNodes.length;
i++)<BR>                                                {<BR>                                                        var
linkId = $("item_id",
xmlDoc).item(i).firstChild.data;<BR>                                                        output
+= '<tr>';
<BR>                                                        output
+=
'<td>'+linkId+'</td>';<BR>                                                        output
+=
'</tr>';<BR>                                                }
<BR>                                                output
+=
'</tbody></table>';<BR>                                                $('#itemtable'+idsource).html(output);<BR>                                        });
<BR>                                })<BR>                                });<BR><BR>but
this seems to cough up errors about linkId not being a function..... Am I at
least on the right path?<BR><BR>What this code does is everytime one clicks
on a "dt" element, it sends the request based on the id.... (just a number)
then it submits the ajax request. I'm really not sure at all how to deal
with the object it returns... so that's why you see me treating it just like
I would any other xml object. <BR><BR>I'd be happy to post all my code but I
don't want to suck up a ton of bandwidth... this being my first post and all
that.....<BR><BR>(In a future revision of this code, I'll actually let the
accordian wait until the object is returned before I slide it down.....)
<BR><BR>Thanks,<BR>-Jim<BR><BR><BR>.-*** Message Scanned by Alachua County
McAfee Webshield Appliance
***-.<BR>_______________________________________________<BR>jQuery mailing
list<BR><A href="mailto:discuss@jquery.com">discuss@jquery.com</A><BR><A
href="http://jquery.com/discuss/">http://jquery.com/discuss/</A><BR></BLOCKQUOTE></DIV><BR>
<DIV>
<P>
<HR>
.-=== Message Scanned by Alachua County McAfee Webshield Appliance ===-.
<P></P></DIV></BLOCKQUOTE>
<DIV><P><HR>
.-*** Message Scanned by Alachua County McAfee Webshield Appliance ***-.
</P></DIV>
</BODY></HTML>
_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/