Use PHP code in external Javascript file

前端 未结 5 411
甜味超标
甜味超标 2020-12-01 05:54

I am just wondering if it\'s possible to use external JS file that contains PHP code.

my external JS

$(document).ready(function(){

    $(\'#update\         


        
5条回答
  •  时光说笑
    2020-12-01 06:30

    quite a common thing to want to do, just rename your js file to "external.js.php" (i use that method, but as long as it ends in php it doesn't matter what you use really) then just change the src url in your script tags and away you go.

    Dont forget you may need to include function and config files into the javascript for that base_url() function to work.

提交回复
热议问题