Is there a way to launch an event after html() has been fired? Such as:
$.post("ajax.php", {data :data}, function(data){
$("#countries").html(data, function(){
alert("test");
});
});
This is not working.
EDIT: I am asking this because I want to do few things(another call) with the information coming from the call… I wanted to simplify the example…I guess programmers always want to know why…
So here it is the example updated
$.post("ajax.php", {data :data}, function(data){
$("#countries").html(data, function(){
var id = $("#countries option:selected").attr("id");
getRegions(id);
});
});
Yes you can…
However, like everyone else says, it is unnecessary as
.html()is synchronous, so you can just put your code following it rather than in a callback.Demo: http://jsfiddle.net/billymoon/a49P4/