i think its because you are binding the handler to a DOM element
before it exists

if you use the 'live' method you may get what you want

ie

$().ready(function() {
    $('#submit1').live('click', function() {
        alert('it works!');
    });
});

alternately, bind the event handler *after* the content is loaded via
ajax


On Nov 24, 7:39 am, Rockinelle <[email protected]> wrote:
> I am jumping into ajax with Jquery and I have what I think is an easy
> question. I have successfully used jquery load to bring an external
> php doc into my page. That page has a form on it where I want to use
> jquery to reload that external page to reload with ajax when the form
> is submitted. What I need to know is where to put the code to act on
> the external form. Do I place the code on the page .load ing the
> external form or do I need to place it on the external form?
>
> I've tried it both ways and I can't get it to work.
> For testing I'm just doing something simple
> $(document).ready(function(){
>                 $('#submit1').click(function(){
>                         alert('It works!');
>                 });
>         });
> This code does work when it's located on the external form and I load
> that form explicitly rather than through an ajax call. What am I
> missing?
>
> I guess my question has a greater scope than just this example. Will
> javascript on a main page act on selectors that match those in a div
> that's loaded through ajax? The same question with CSS too.

Reply via email to