繁体   English   中英

如何在脚本中分配php定义常量值

[英]How can i assign php define constant value in script

这基本上是一个ajax响应,我想从我存储在常量中的配置文件中分配位置

define(BASE_URL, "http://example.net/lc-latest/");
$website =  BASE_URL ;

这是我的示例页面代码脚本:

if (response["success"] == true) {
    $("#showMessage").html(response['message']);
    location = "/lc-latest/gdpi.php?jobid="+response["id"]

    /* I want to re write this link as `$website` so that if I changed
    the project location it should not disturb.*/

    location = "<?php BASE_URL ?>gdpi.php?jobid="+response["id"] //can i write like this in script of ajax response.?
    window.open(location);
  }

您可以像这样将BASE_URL变量保存为html

<body base_url="<?php echo BASE_URL ?>">

然后在你的ajax响应中使用jQuery读取它,就像这样

location = $('body').attr('base_url') + "gdpi.php?jobid="+response["id"]

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM