How to insert PHP into jQuery?

后端 未结 2 859
萌比男神i
萌比男神i 2021-01-24 09:01

I understand that one can\'t execute PHP from the client side (JavaScript), but what would then be the appropriate approach? Writing my jQuery in PHP? Here is an example of what

2条回答
  •  南笙
    南笙 (楼主)
    2021-01-24 09:21

    First, you should wrap js-code with script-tag:

    
    
    
    
    
    

    If you want to pass some data from PHP to JS use echo:

    
    

    where $image-php variable. In general you may generate any JS code using PHP as well as html.

    To pass data from JS to PHP (from client to server) use AJAX

    I hope this will help.

提交回复
热议问题