Use a jQuery script so it can work without having to call the url
<p>Is there a way I can use this script so it can work without having to call the <code>url: "http://localhost/a/rate/update.php"</code></p>

<p>Here is the script.</p>

<pre><code>function getRatingText(){
    $.ajax({
        type: "GET",
        url: "http://localhost/a/rating/update.php",
        data: "do=getavgrate",
        cache: false,
        success: function(result) {
            // add rating text
            $("#rating-text").text(result);
        },
    });
}
</code></pre>
