How to access PHP session variables from jQuery function in a .js file?

前端 未结 7 1169
轮回少年
轮回少年 2020-11-28 10:50

How to access PHP session variables from jQuery function in a .js file? In this code, I want to get \"value\" from a session variable

$(function() {
   $(\"#         


        
7条回答
  •  一个人的身影
    2020-11-28 11:24

    You can produce the javascript file via PHP. Nothing says a javascript file must have a .js extention. For example in your HTML:

    
    

    Then your script file:

    
    
    $(function() {
        $( "#progressbar" ).progressbar({
            value: 
        });
    
        // ... more javascript ...
    

    If this particular method isn't an option, you could put an AJAX request in your javascript file, and have the data returned as JSON from the server side script.

提交回复
热议问题