Understanding jQuery.get()

Understanding jQuery.get()

Hello. I am pretty new to jQuery and AJAX in general, and I am trying to figure out how exactly the jQuery.get() function works. I am writing a web application that pulls some html data from a php script, updates a div with that data, and updates that div's scrollbar (using the tinyscrollbar plugin) to "fit" the new contents.
Here is my code:
  1. $(".menu").click(function(){
  2. var oldContent = $("#dyn").html();
  3. $.get("populate.php", {name: cleanMeUp($(this).html())}, function(data, statusMsg){ //gets page from server based on what menu item was clicked
  4. if (data != "blank") {
  5. $("#dyn").html("<h3>Loading...</h3>");
  6. $("#dyn").html(data);
  7. } else $("#dyn").html(oldContent);
  8. scrollbar.update();
  9. },
  10. "html");
  11. });
I have highlighted the line of code that does not do what I expect. I would expect this code to load the div with new contents and call scrollbar.update() when it receives the data from the server and updates the DOM. However, when I view the site in Chrome or IE8, the scrollbar does not usually update. Is there a way to run the scrollbar.update() function only AFTER the DOM has been updated with data from the server?

Like i said, I am a newbie and not ashamed to admit it. I would really appreciate some help. Thank you so much.