views:

174

answers:

3

I need certain scripts to refire after an AJAX load. How could I accomplish this?

+5  A: 

You could use the success callback to invoke the functions you want to refire.

$.ajax({
    url: '/url',
    success: function() {
        func1();
        func2();
    }
});
Darin Dimitrov
This is great. I'm using the `$.ajax({ type: "GET", url: "test.js", dataType: "script" });` from the jQuery website to get the scripts, but would it be possible to create a database of sorts and have it refire certain scripts when loading certain pages?
Alexsander Akers
A: 

Use the callback function

A callback is a plain JavaScript function passed to some method as an argument or option. Some callbacks are just events, called to give the user a chance to react when a certain state is triggered. jQuery's event system uses such callbacks everywhere:

More info here

rahul
A: 

If you just need to reattach events try the live method.

Dave