Passing parameters to PHP via a link like http://somesite.ru/script.js

Greetings! Such a task, there is a php site and an html site. You need to add code like this on the html site

<script type="text/javascript">
var a = 1;
var b = 2;
var c = 3;
</script>
<script type="text/javascript" src="https://php.ru/script.js"></script>

script.js – receives variables, receives data from the database based on them and returns js code

For example: google adsense.

The question is how to get the variables a, b, c in script.js?


Answer 1, authority 100%

the easiest way, without editing server configs.

<script type="text/javascript" src="https://php.ru/script.js"></script>

change to:

<script type="text/javascript" src="https://php.ru/script.php?var1=val1&var2=val2"></script>

where var1,2 is the name of the variables and val1,2 is their value, respectively

Added:
if you mean dynamic loading of scripts, then the easiest way is to use jQuery:

<script type="text/javascript">
        $(document).ready(function(){
            $("head").append("<script type=\"text/javascript\" src=\"http://php.ru/script.php?var1=val1&var2=val2\"><\/script>");
        });
</script>

Answer 2, authority 50%

easy to do
<script type="text/javascript" src="https:///script.php?"></script>
and based on the data generate javascript from php

additive. enter recall then by the name of script.js in the .htaccess file, passing parameters to the php script [L]