You're right, I had pasted the code snippet from another script and
forgot to change the code. I do only have a question though. If am
only meaning to look for an ID that only exists once, what would be
the syntax for that?
For example, right now I have

$(html).find('#invoice').each(function(){
     var invalidDiv = $(this).text();
     alert(invalidDiv);
});

If I remove each, how do I call the function that is previously
contained in each?

$(html).find('#invoice')

function(){   <----------------------------------Where do I put this
function?
     var invalidDiv = $(this).text();
     alert(invalidDiv);
}

Also, on the topic of getting data from a server, right now I am
getting html back from the server and parsing that, however, should I
be using JSON or XML instead? Are these alternative better than html?
HTML is just what I have seen demonstrated so I have just been trying
it out but I am certainly open to new and better ideas.

~Dustin

On Aug 30, 12:55 pm, "Josh Nathanson" <[EMAIL PROTECTED]> wrote:
> I notice you are running an "each" method when the "find" is looking for an
> id ("#invoice").  This implies that you are looping over multiple elements
> with the same id.  This will mess things up as it is invalid to have
> multiple elements with the same id.  Try using "invoice" as a class rather
> than an id in your html.
>
> <li class="invoice">invalid</li>
>
> -- Josh
>
> ----- Original Message -----
> From: "John Resig" <[EMAIL PROTECTED]>
> To: <jquery-en@googlegroups.com>
> Sent: Thursday, August 30, 2007 9:36 AM
> Subject: [jQuery] Re: $(html) error...I think. Please help, I'm stumped!
>
> > What version of jQuery are you using?
>
> > --John
>
> > On 8/30/07, Dustin Martin <[EMAIL PROTECTED]> wrote:
>
> >> Hello everyone! My name is Dustin and was hoping I could get a little
> >> help with a JQuery problem  I've run into. I just started using JQuery
> >> and have been trying out a little AJAX when I ran into a problem. In
> >> Firefox (using Firebug) I get the error:
>
> >> ret[i].getElementsByTagName is not a function
> >> r = jQuery.merge( r, ret[i].getElementsByTagName( tag ));
>
> >> Here is my Javascript code where the error appears to be.
>
> >>                 $.ajax({
> >>                     url: 'CS_AJAX_Server_Responder.cfm',
> >>                     type: 'POST',
> >>                     dataType: 'html',
> >>                     timeout: 30000,
> >>                     data:
> >> {Invoice:invoiceNum,Store:storeNum,Div:divNum,invoicevalidate:'true' },
> >>                     error: function(){
> >>                         $('#loadingimg').fadeOut("slow");
> >>                         alert('Error accessing server. Please try
> >> again.');
> >>                     },
> >>                         success: function(html){
> >>                                 $('#loadingimg').fadeOut("slow");
> >>                                 alert('test message');
>
> >>                             $(html).find('#invoice').each(function(){
> >>                                 var invalidDiv = $(this).text();
> >>                                         alert(invalidDiv);
> >>                             });
> >>                         }
> >>                 });
> >>         }
> >> }
>
> >> My server side code is very simple.
>
> >> <ul><li id="invoice">invalid</li></ul>
>
> >> The error appears to be caused by $(html).find() but I really do not
> >> have a clue as to why.  Once I remove the  $(html).find() code it no
> >> longer throws the error. The frustrating thing is that I had
> >> everything working yesterday but it does not work any longer and I
> >> have no idea what I changed that could have led to this error. In IE I
> >> don't get any error but it doesn't proceed through the code like
> >> normal. Please, any insight and help would be appreciated...this has
> >> been driving me up the wall.

Reply via email to