Getting variable value from PHP with jQuery

前端 未结 4 1494
一向
一向 2021-01-16 07:50

So how do i get variable value from php file with jquery...? the jquery code is in other file (tpl)

for example i have register.php and register.tpl (template file f

4条回答
  •  有刺的猬
    2021-01-16 07:59

    Best bet is to output the PHP variable as a hidden field or a JavaScript variable:

    
    
    // access it like this:    
    alert($('#my_var').val());
    

    or

    
    
    // access it like this
    alert(my_var);
    

    That should do it :-)

提交回复
热议问题