检索运行时的注释?

I want to call Ajax which fetches all the comments from database.

Now how to put a check on that Ajax Script to Run, when only someone comments.

Same as the stackoverflow notifications. When we comment on question, The Notification appears without reloading page (i.e On Runtime ).

Right now I am Running the same Ajax Script after each 10 seconds again and again, when I think is a bad way .So Here is my working Ajax Code:

$(document).ready(function(){
    setInterval(function(){
        $.ajax({
            type: "GET",
            url: "ajax_files/reload_notifications.php"
        }).done(function(result) {
            var $notifications = $('#notification_area');
            if ($notifications.length > 0) {

                $notifications.html(result);

            }
        });
    }, 10000);
});

When a comment is entered, do a similar AJAX request that will save the comment and on it's success callback, call another function which will also hit another AJAX request which fetches the comments. For e.g.

 function insertComment() {
   $.ajax({
        type: "GET",
        url: "ajax_files/insert_comment.php"
      }).done(function(result) {
          fetchComments();
        }
   });
 }

 function fetchComments() {
   $.ajax({
        type: "GET",
        url: "ajax_files/reload_notifications.php"
     }).done(function(result) {
        var $notifications = $('#notification_area');
        if ($notifications.length > 0) {

            $notifications.html(result);

        }
   });
 }

Hope this helps!