是否可以使用smarty、php、JQuery从另一个页面获取值?[无跨域]
我正在处理smarty模板文件 模板引擎的核心php使用ioncube编码 因此,我被限制只能在某些页面上获取某些值 比如说, 我仅在clientReadDetails.php 在clientprofile.php上,是否可以使用smarty、php、JQuery从另一个页面获取值?[无跨域],php,jquery,smarty,Php,Jquery,Smarty,我正在处理smarty模板文件 模板引擎的核心php使用ioncube编码 因此,我被限制只能在某些页面上获取某些值 比如说, 我仅在clientReadDetails.php 在clientprofile.php上,{$clientemail}的值为空 那么,是否可以使用smarty、php、JQuery从另一个页面获取值 我的所有页面仅驻留在单个域上 任何帮助都将不胜感激 谢谢您应该从PHP端将所有需要的变量分配给Smarty。不要为此使用Ajax 如果脚本中的$clientemail是一个
{$clientemail}
的值为空
那么,是否可以使用smarty、php、JQuery从另一个页面获取值
我的所有页面仅驻留在单个域上
任何帮助都将不胜感激
谢谢您应该从PHP端将所有需要的变量分配给Smarty。不要为此使用Ajax 如果脚本中的
$clientemail
是一个固定值,最好的方法是在PHP文件中保留一个包含所有值的中央配置数组,包括每个脚本实例中的该文件(包括“conf.PHP”
),并将该数组作为Smarty变量传递
$conf = array();
$conf["clientemail"] = "xyz@domain.com";
...........
$Smarty = new Smarty(); // or whichever way you do it
$Smarty->assign("conf", $conf);
............
Then in the template:
{$conf.clientemail}
如果$clientemail
是用户输入的值,则可以将其存储在$\u SESSION
中(如果正在运行会话),然后获取:
In the PHP script that processes the form:
$_SESSION["clientemail"] = ..... wherever clientemail comes from
...........
$Smarty = new Smarty(); // or whichever way you do it
$Smarty->assign("clientemail", $_SESSION["clientemail"]);
............
Then in the template:
{$clientemail}
请注意,如果用户打开两个或多个窗口并同时填写同一表单,此示例将给您带来麻烦:
$\u会话[“clientemail”]
将被每次提交的表单覆盖 请更详细地描述$clientemail
的来源。@Pekka:$clientemail是用户输入的值非常同意。通过ajax实现这一点是非常蹩脚的。