Good point, thanks for noticing that, Brian.

This is a good example of why it's always helpful to post a link to a live
test page instead of just a code snippet. Then we know what the actual code
looks like and can see it run in the browser.

-Mike

On Mon, Dec 14, 2009 at 4:20 PM, brian <zijn.digi...@gmail.com> wrote:

> $('#somediv').append(html);
>
> You're appending to the div with ID 'someDiv'. But you say that this
> is the content:
>
> <div class="somediv">
>       <form id="someform">
>               <p class="someclass">Name:</p>
>                       <input style="display: none;" type="textbox"
> name="somefield"
> value="test" />
>               </p>
>       </form>
> </div>
>
> Note the class="somediv". I'm wondering if that's a typo and it's
> actually id="somediv", in which case you'll have 2 divs with identical
> IDs.
>
> Just a shot in the dark.
>
> On Mon, Dec 14, 2009 at 11:05 AM, joseph7 <radioak...@gmail.com> wrote:
> > Hi,
> >
> > So, I'm attempting to add HTML to a document via Ajax, but when I get
> > back the content, I'm finding that no matter what I try, I can't get
> > it added to the DOM correctly. Basically I'm doing this:
> >
> > $.post('ajax.php',
> >     function (data) {
> >          var html = data.content;
> >          $('#somediv').append(html);
> >     }
> > );
> >
> > The HTML I'm loading looks like this:
> >
> > <div class="somediv">
> >        <form id="someform">
> >                <p class="someclass">Name:</p>
> >                        <input style="display: none;" type="textbox"
> name="somefield"
> > value="test" />
> >                </p>
> >        </form>
> > </div>
> >
> > While the content does show up in the div, if I try to get the form by
> > doing $('#someform'), jQuery returns nothing. I've tried using .append
> > () and .html(), and neither way gives me what I want. Is there
> > something I'm missing here? I know adding objects to the DOM in jQuery
> > is ridiculously easy, so I feel like I'm either running up against
> > something impossible, or I have a hugely flawed concept of how append
> > () and html() work.
> >
>

Reply via email to