我该如何分配PHP定义脚本

问题描述:

恒定值,这基本上是一个Ajax响应我要指派从配置文件位置我都存储在不断我该如何分配PHP定义脚本

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); 
    } 
+0

如果你改变了项目的位置,你不能只是改变你的定义语句? –

+0

@RossWilson是的,我会改变定义,我问我如何给base_url作业页面scrpt ..? –

+1

''应该可以工作 – FrankerZ

你可以保存HTML中的BASE_URL变量就这样

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

,然后在你的Ajax响应阅读它使用jQuery就像这样

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