In that case you would need to add something like
html = '<div>'+html+'</div>'; to your function. Its a bit of an ugly hack I know. Having played with it a bit now. I think your probably right about it being a jquery bug. It might be worthwhile exploring which function the problem lies with then submitting it to the jquery team. R On Apr 13, 10:55 pm, Nic Hubbard <nnhubb...@gmail.com> wrote: > Hey, that actually worked! But, why would this have helped? And, is > there a way around this, since the real form that I need to get, I > cannot wrap a div around. > > On Apr 13, 2:46 pm, Ryan <ryank...@gmail.com> wrote: > > > If you wrap your form in a div I think it should work - haven't tested > > it > > > R > > > On Apr 13, 10:22 pm, Nic Hubbard <nnhubb...@gmail.com> wrote: > > > > Could this be a jQuery bug? > > > > On Apr 13, 2:13 pm, James <james.gp....@gmail.com> wrote: > > > > > I still haven't figured it out, but playing around and setting the > > > > ajax response as a jquery object, $(html), and making it global so I > > > > can view it's attributes through Firebug, I was able to locate the > > > > form element on the ajax response. It was the index-5 element for your > > > > test page. My sample code below. Though this still doesn't help as to > > > > why we can't reference it using #test2, maybe someone else can get > > > > something more out of it. > > > > > I've also tried appended the response to the page and still no go. > > > > > -------------------------------------------------- > > > > > var globalHTML; // global variable > > > > > $(document).ready(function() { > > > > > $.ajax({ > > > > url: 'http://www.puc.edu/dev/tests/linking-test', > > > > type: 'GET', > > > > success: function(html) { > > > > var $html = $(html); // wrap response as > > > > jquery object > > > > > globalHTML = $html; // check object with > > > > firebug > > > > > alert( $html.get(5).action ); > > > > } > > > > }); > > > > > }); > > > > > Using Firebug and looking at the attributes of the object I've found > > > > that the form is on the 5th-index of the object, for your test page. > > > > Though this still doesn't really help much > > > > > alert( $(html).get(5).action ); > > > > > On Apr 13, 10:28 am, Nic Hubbard <nnhubb...@gmail.com> wrote: > > > > > > Ok, my test now reflects your suggestions. But, sadly, none of that > > > > > helped, it is still returning undefined. :( > > > > > > On Apr 13, 1:03 pm, Nic Luciano <adaptive...@gmail.com> wrote: > > > > > > > Hey Nic, > > > > > > > I have a couple small recommendations- hopefully one will fix the > > > > > > issue. > > > > > > > Try using $.get() instead of $.ajax, and specify "type" option as > > > > > > "html"- > > > > > > alternatively, you can use $.load() if your ultimate purpose is to > > > > > > inject > > > > > > this HTML into DOM. > > > > > > > In addition rather than using find(), just select by ID as a subset > > > > > > of the > > > > > > DOM node.. > > > > > > > alert($(html).find("#test") becomes > > > > > > alert($("#test", html)); > > > > > > > Hope some of this helps... cheers! > > > > > > > Nic Luciano > > > > > > Senior Web Developer @ > > > > > > AdaptiveBluehttp://www.twitter.com/niclucianohttp://www.linkedin.com/in/nicluciano > > > > > > > On Mon, Apr 13, 2009 at 3:35 PM, Nic Hubbard <nnhubb...@gmail.com> > > > > > > wrote: > > > > > > > > Nope, that does not work either. > > > > > > > > On Apr 13, 12:20 pm, Jack Killpatrick <j...@ihwy.com> wrote: > > > > > > > > Maybe try: > > > > > > > > > success: function(html){ > > > > > > > > alert($(html).find('form').attr('action')); > > > > > > > > > I had some issues in the past using form id's with the jquery > > > > > > > > form > > > > > > > > plugin, but usually getting it using 'form' worked. > > > > > > > > > That said, since the response isn't in the DOM yet, I'm not > > > > > > > > sure if that > > > > > > > > might present an issue (too/instead). > > > > > > > > > - Jack > > > > > > > > > Nic Hubbard wrote: > > > > > > > > > Yes, this is very odd. I have tried it quite a few ways, but > > > > > > > > > I can > > > > > > > > > never target the form. Any other ideas? > > > > > > > > > > It is frustrating because I really need to target a form in > > > > > > > > > the html > > > > > > > > > response... > > > > > > > > > > On Apr 13, 11:45 am, James <james.gp....@gmail.com> wrote: > > > > > > > > > >> That's strange. I can't get it to work either and I'm > > > > > > > > >> getting the same > > > > > > > > >> results as you (I can get #test2, but not #test). I've even > > > > > > > > >> truncated > > > > > > > > >> the response down to as if you're only receiving the <form> > > > > > > > > >> part and > > > > > > > > >> it still doesn't work. I'd be interested in seeing what > > > > > > > > >> happens here > > > > > > > > >> too. > > > > > > > > > >> On Apr 13, 6:47 am, Nic Hubbard <nnhubb...@gmail.com> wrote: > > > > > > > > > >>> Test page to show the > > > > > > > > >>> problem:http://www.puc.edu/dev/tests/ajax-test > > > > > > > > > >>> On Apr 13, 9:33 am, Nic Hubbard <nnhubb...@gmail.com> wrote: > > > > > > > > > >>>> I am pulling my hair out over this. I swear that this is > > > > > > > > >>>> a bug. > > > > > > > > > >>>> For some reason, I CANNOT target any forms within the html > > > > > > > > >>>> response. > > > > > > > > >>>> I have tried very simple examples and it still won't work. > > > > > > > > >>>> Here is > > > > > > > > >>>> what I have, that still returns undefined: > > > > > > > > > >>>> HTML: > > > > > > > > >>>> <form id="test" action="http://test.com"> > > > > > > > > >>>> <span id="test2">this is my text</span> > > > > > > > > >>>> </form> > > > > > > > > > >>>> jQuery: > > > > > > > > >>>> success: function(html){ > > > > > > > > >>>> alert($(html).find("#test").attr('action')); > > > > > > > > >>>> alert($(html).find("#test2").text()); > > > > > > > > > >>>> } > > > > > > > > > >>>> #test2 works, but #test never does, and it seems this is > > > > > > > > >>>> because it > > > > > > > is > > > > > > > > >>>> a form. Have I done something wrong here? Can I not > > > > > > > > >>>> target a form? > > > > > > > > > >>>> On Apr 12, 4:35 pm, Nic Hubbard <nnhubb...@gmail.com> > > > > > > > > >>>> wrote: > > > > > > > > > >>>>> I have an ajax GET call that returns the HTML of a page > > > > > > > > >>>>> on my > > > > > > > server. > > > > > > > > >>>>> Within that page is a form with a specific ID. I know it > > > > > > > > >>>>> is there, > > > > > > > I > > > > > > > > >>>>> can see it in the response in Firebug, but when I try to > > > > > > > > >>>>> get > > > > > > > > >>>>> attributes of that ID, it always returns undefined! What > > > > > > > > >>>>> have I > > > > > > > done > > > > > > > > >>>>> wrong here? > > > > > > > > > >>>>> success: function(html){ > > > > > > > > > >>>>> $(html).find('#main_form').each(function() { > > > > > > > > >>>>> var linking_data = $(this).serialize(); > > > > > > > > >>>>> var form_action = $(this).attr('action'); > > > > > > > > >>>>> alert(form_action); > > > > > > > > > >>>>> }); > > > > > > > > >>>>> } > > > > > > > > > >>>>> I have tried to not use each() and that still returns > > > > > > > > >>>>> undefined. I > > > > > > > > >>>>> don't get it.