[jQuery] 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=513514620-06032007><FONT face=Arial color=#0000ff size=2>thank
you immensely for all your help. I'll start rewriting the accordion code in a
day or so.</FONT></SPAN></DIV>
<DIV><SPAN class=513514620-06032007><FONT face=Arial color=#0000ff
size=2>-Jim</FONT></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> Tuesday, March 06, 2007 3:30 PM<BR><B>To:</B> jQuery
Discussion.<BR><B>Subject:</B> Re: [jQuery] rewriting generic ajax jQuery
style<BR><BR></FONT></DIV>Jim, you can use the siblings() exactly as you put
in your code, the only thing you should watch out for is siblings() will
return a group of jQuery objects, which in your case doesn't matter as item_id
only has a single sibling, item_name. When you chain text() to a group of
jQuery objects, only the first jQuery object returns its text. I'm not up on
performance issues with jQuery, like I said before, there are a couple of ways
of doing this, and you typically (in my experience) won't see performance
differences between methods (say using XPath instead of CSS or find()) until
you start dealing with a large (300+) dataset (at which point I'd forgo ajax
and just deliver using html). <BR><BR>- jake<BR><BR>
<DIV><SPAN class=gmail_quote>On 3/6/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">Ok,
here's another question.... I've got this code
working:<BR><BR>$(document).ready(function()
{<BR> $('#resultcontainer').accordion();<BR> $("dt").click(function(){
<BR> idsource
=
$(this).attr("id");<BR> $.ajax({<BR>
type:
"GET",<BR>
url: "
getItems.php",<BR>
data: {cat_id:
idsource},<BR>
dataType:
"xml",<BR>
success: function(xml){
<BR> //build
a table from xml
results.<BR> var
output = '<table><thead><tr><th>Items
Available</th></tr></thead><tbody>';
<BR> //create
rows for each
result.<BR> $("item_id",
xml).each(<BR>
function() {
<BR> var
linkId =
$(this).text();<BR> output
+=
'<tr>';<BR> output
+= '<td>'+$(this).text()+'</td>';
<BR> output
+= '<td><a href="itemdetail.php?item_id='+linkId+'"
>'+$(this).siblings().text()+'</a></td>';<BR> output
+= '</tr>';
<BR>
}<BR> )<BR> output
+=
'</tbody></table>';<BR> $('#itemtable'+idsource).html(output);
<BR>
}<BR> })<BR> })<BR> });<BR><BR>I
just looked for a "nextSibling" style analouge in jQuery. Would it be more
benificial to change the node I am getting out of the XML file and grab both
its children? or is this method ok?. Which one would be faster? Selecting
two children? or selecting siblings?
<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/