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
2009-11-09 13:10:38
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
2009-11-09 16:33:41
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
2009-11-09 13:12:16