将javascript对象发送到服务器然后使用php处理它并用此对象替换.js文件内容

I'm trying to update existing .js file on the server with ajax and php the whole content of the .js file must be replaced with the created object objcurrency

The Idea is that index.html page is the website which makes ajax request for data.js every minute and inside this data.js there is object with currency rates strings.

And i have panel.html that is accessed with username and password where i can change these currency rates string on the server. So when i want to change the currency rates people who have opened the website will get currency rates that i updated instead of refreshing the page

    function ajaxPost(obj){
    $.ajax({
        type: "POST",
        url: "js/data.js",
        contentType: 'application/json',
        data: JSON.stringify(obj),
        dataType: 'json'    
        });
}



 $(document).ready(function(){      
                $('#update').on('click', function(){
                    var objrates = {
                        EURbuy : $('#eurbuy').val(),
                        EURsell : $('#eursell').val(),
                        USDbuy : $('#usdbuy').val(),
                        USDbuy : $('#usdbuy').val()
                    };
                    ajaxPost(objrates);
                });                                                                                                                                                                                                                         
            }); 

Edits:

Searched some things and came to this so far now i have to add php code that replaces data.js(file content) on the server with $json

<?php 
    $json = file_get_contents('php://input');

?>