One way for doing message load asynchronously is using Javascript “jQuery” Library:
1) You can make request POST||GET request with jQuery to PHP File Like this:
$.post("path/to/phpfile.php",{"loadmessages":"*"},function(data){
console.log(data); //Here will be loaded PHP file echo data;
});
2) Then you must make PHP file like this
if(isset($_POST['loadmessages'])){
//get messages from mysql then echo them
echo "response";
}
3) then you can append that response to your chat pool with jQuery.