The answer is already indicated in the comments, but to explain this a bit:
The html method does not call a callback, it is just a function that returns a jQuery object when a parameter is specified (or the contents of the html otherwise).
Say, for example, when stuff is a very large line containing a lot of html and this will slow down your script, the rest of the script will wait until the html is in place.
What you requested is certainly possible:
var stuff = '<div id="new">This is a placeholder text</div>'; $('#content').html(stuff); $('#new').text('This is the real text');
But if stuff loaded via ajax using .load() , the third line should be in the callback to replace the placeholder text as soon as the html is received from the server:
$('#content').load('content.php', function() { $('#new').text('This is the real text'); });
which is nothing more than a shortcut for this:
$.ajax({ url: 'content.php', success: function(data) { $('#content').html(data); $('#new').text('This is the real text'); } });
jazZRo
source share