i'm new to web and facing issue while using PHP file's constants inside javascript Ajax call.
My PHP code in constants.php file is as:
<?php
$color = 'green';
define ('BASE_URL', 'https://example.com?');
define ('APP_KEY', 'abcde');
define ('USER_KEY', '12345');
?>
My Ajax call in another login.php file is as:
<script type="text/javascript" charset="utf-8">
$(document).ready(function() {
$("#loginPopup").on('click',function(){
var x = document.forms["login"]["emailId"].value;
var pwd = document.forms["login"]["pwd"].value;
$.ajax({
type: 'GET',
url: 'BaseURL?appkey=abcde&userkey=12345&email='+ x +'&password=' + pwd,
crossDomain: true,
dataType: 'jsonp',
success: function (response) {
showAlert(response);
},
error: function (request, status, error) {
alert("ERROR");
}
});
});
});
</script>
I want to move constants i.e. Base URL, Keys etc to constants file. So i've created constants.php. But now, i don't know how to use that inside ajax call. Please help. Thanks in anticipation.