Abdul Waheed Abdul Waheed - 4 months ago 20
Ajax Question

How can i assign php define constant value in script

This is basically an ajax response I want to assign location from config file I have stored in constant

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

This is my example page code script:

if (response["success"] == true) {
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.?


you can save the BASE_URL variable in html just like this

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

and then in your ajax response read it using jQuery just like this

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