更改与阿贾克斯PHP变量 [英] change php variable with ajax

查看:81
本文介绍了更改与阿贾克斯PHP变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个这样的PHP变量:

I have an php variable like this:

PHP code:

$php_value = 'Am from PHP';  

和我希望能够与jQuery改变这个变量和jQuery是在同一页上?

And I want to be able to change this variable with jQuery and the jQuery is on the same page?

推荐答案

您不能。

由当时的页面已经被交付给浏览器,JavaScript的运行后,生成的页面将完成运行,该变量将不再存在的PHP程序。

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将允许您的新数据发送到服务器(Ajax的),其中该服务器可以存储数据的某处的(一个数据库是通常的),并读取响应

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也将允许你修改的页面在浏览器(DOM)(包括包含在一个Ajax请求的响应中的数据)。

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).

这篇关于更改与阿贾克斯PHP变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆