[英]Get key using javascript callback like Google map api do
I have a script.js file which listen various events (click, right click, copy page contact, etc).我有一个 script.js 文件,它监听各种事件(单击、右键单击、复制页面联系人等)。 I add this script.js file in index.php file which is on different server using
<script src="script.js">
tag.我使用
<script src="script.js">
标签在不同服务器上的 index.php 文件中添加了这个 script.js 文件。
Here, I pass key on that script tag such as, <script src="script.js?key=134">
to differentiate customers who use script.js file.在这里,我在该脚本标签上传递密钥,例如
<script src="script.js?key=134">
以区分使用 script.js 文件的客户。 So different server or customer has different keys.所以不同的服务器或客户有不同的密钥。
I want to return that key back from index.php server file to script.js file on each event happen.我想在每个事件发生时将该密钥从 index.php 服务器文件返回到 script.js 文件。
How can I return that key to the server to that script.js file on each event happen?如何在每个事件发生时将该密钥返回到该 script.js 文件的服务器?
Could you perhaps have a script tag above this one like the following?你能不能在这个上面有一个脚本标签,如下所示?
<script>
var CONFIG = {
key: <?php echo $key; ?>
}
</script>
And then you can access CONFIG.key
in your script.js.然后你可以在你的 script.js 中访问
CONFIG.key
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.