获取facebook数据php和javascript

so i am trying to fetch some basic data from facebook and display it in plain text with this simple php and js code , it seems to work, but the problem is - if i change the url of getJSON , it does add the new JSON to the file, but after 2sec delay it adds the previous fetched JSON data to the data.json file , it is really confusing for someone like me, anyone could give me some hints? Thank you!

<?php

if(isset($_POST['data'])) {
  file_put_contents('data.json', $_POST['data']);
}

$file = json_decode(file_get_contents('data.json'),true);
foreach ($file['data'] as $one) {
  if(strpos($one['message'], 'it') > -1) {
    echo '<p> ' . $one['from']['name'] . ' : ' . $one['message'] . '</p>';
  }
}

?>
<script src="https://code.jquery.com/jquery-2.2.2.min.js"></script> 
<script>
setInterval(function () { 
    $url = "https://graph.facebook.com/21785951839_10155105722796840/comments/?filter=toplevel&order=reverse_chronological&summary=true&access_token=mytoken";
    $.getJSON($url, function( data ) {
        $.post('index.php',{
            data: JSON.stringify(data)
        },function(data) {

        });
    });
}, 2000);
</script>