这基本上是一个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);
}
你可以像这样在html中保存BASE_URL变量
<body base_url="<?php echo BASE_URL ?>">
然后在ajax响应中使用jQuery读取,就像这样
location = $('body').attr('base_url') + "gdpi.php?jobid="+response["id"]