AJAX同时发布到不同的PHP页面

I have a page user.php which is a template for different users pages (e.g. user.php?id=5). I run an AJAX script to monitor the database for new messages posted during a conversation with each user.

My problem is that when I post a message to user.php?id=5 it also appears on user.php?id=1 etc.

How do I ensure the real-time message is only sent to the correct user?

Script in user.php:

var refreshId = setInterval(function () {
    $.ajax({
        url: 'another_file.php',
        data: { 'action': '<?php echo $lastID; ?>' },
        dataType: 'json',
        type: 'post',
        success: function (data) {
            var avatar = '<img src="images/avatars/' + data[1].avatar + '"/>';
            if (compare_id != data[0].cr_id) {
                $('#responses').prepend("<div class='row'><div class='col-xs-12'><div class='post_container_left_small' style='float:left;'><div class='reply_avatar'><div id='add_button_small'>" + avatar + "</div></div><div class='reply_text'><h3><span class='post_time'>now</h3>" + data[0].reply + "</div></div></div></div>");
            }
            compare_id = data[0].cr_id;
        },
        error: function(xhr, desc, err) {
            console.log(xhr);
            console.log("Details: " + desc + "
Error:" + err);
        }
    });
}, 7500);

The php class function it calls:

    public static function getLast($lastID) {

    $lastID = (int)$lastID;
    $result = mysql_query("SELECT * FROM mc_conversation_reply ORDER BY cr_id DESC LIMIT 1");

    $userC = new UserTools();

    while($row = mysql_fetch_array($result)) {
        //echo json_encode($row);

        $userRObj = $userC->get($row['user_id_fk']);

        //echo json_encode($userRObj);
        echo json_encode(array($row,$userRObj));

    }

}

The whole idea is that the user.php is a common "view" (of the mvc model) for users on your app and that by using query parameters you must fetch information for just that user. You have chosen to use AJAX (wich is js and runs only under the view layer of your app, in this case, the user's browser) and therefore you need to have some js code listening to some action in order to have two things done: Have php controller layer update the query parameter id and after that run the ajax request again to fetch the database data and update the html fields.