Two things: 1. You don't have an "id" set for the loadagain button, so jQuery won't be able to find it.
2. That button doesn't exist (yet) after document.ready has completed, so you can't bind it like that. You'll need to use "live" for event delegation: Change $('#loadagain').click(function(){ to $('#loadagain').live("click", function(){