Thanks for the link Jörn, but I solved my problem... let me explain
again what the problem was: after loading new ajax content I had to
run the script in this newly loaded content, but instead of
duplicating the code and put as the FAQ suggested I wanted to run ALL
THE SCRIPT again, so I thought about loading the SAME file again in
the SUCCESS hook, but for some reason the script was being run
multiple times, the more I clicked the more the script was run...

1st click = run 1 time
2nd click = run 2 times
3rd click = run 4 times
4th click = run 8 times

and so on...

What I did to solve this is that I added an unbind command in the end
of my script, something like this, suppose this file is called
"scripts.js"

$(".button").click(function () {
        var job = $(this).attr("id");
        $.ajax({
          type: "GET",
          url: "results.asp",
          data: "job="+job,
          success: function(html){
                  $("div#load").empty().append(html);
                  $.getScript("scripts.js");  <------ HERE I RUN THIS
SAME FILE AGAIN ONCE THE CONTENT IS LOADED
          }
        });
                $(this).unbind('click');  <------ I HAD TO UNBIND THE CLICK TO
PREVENT MULTIPLE EXECUTION
});

Well, it worked as I wanted, the script it being run only one time per
request now.... but I STILL have no idea why the script was being run
multiple times each time I clicked, can someone explain the logic to
me please?

On Dec 3, 5:36 pm, Jörn Zaefferer <[EMAIL PROTECTED]> wrote:
> Feed schrieb:> What am I doing wrong and how can I run the script on the part 
> of the
> > site which has been loaded by ajax?
>
> This should answer your 
> question:http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_st...
>
> Jörn

Reply via email to