Inserting php into js file

前端 未结 5 1049
遇见更好的自我
遇见更好的自我 2021-01-15 01:40

I have a loading gif for the gallery on my website. In my js file I have this code to show the loader:

image: $(\"\"),         


        
5条回答
  •  情歌与酒
    2021-01-15 02:32

    You can't place PHP code directly into a .js file, but you could have some javascript in the head element of your PHP file right before including the javascript file.

    In this javascript you could then define variables and assign data to them using PHP. These variables would then be accessible from inside the javascript file.

    
        
    
        
    
    

提交回复
热议问题