change php variable with ajax

后端 未结 5 430
时光说笑
时光说笑 2020-12-06 08:55

I have an php variable like this:

PHP Code:

$php_value = \'Am from PHP\';  

And I want to be able to change this variable with jQue

5条回答
  •  生来不讨喜
    2020-12-06 09:37

    You can't.

    By the time the page has been delivered to the browser and the JavaScript has run, the PHP program that generated the page will have finished running and the variable will no longer exist.

    JavaScript will allow you to send new data to the server (Ajax), where the server could store the data somewhere (a database is usual), and read the response.

    JavaScript will also allow you to modify the page in in the browser (DOM) (including with the data included in the response for an Ajax request).

提交回复
热议问题