0

Here my jQuery ajax code

jQuery.ajax({
  url:'login.php',
});

How can I add site path in (url:'login.php') like we define site path in php define('SITE_PATH','http://127.0.0.1/project/'); I want to use this SITEPATH in url:'login.php'; to display url:'http://127.0.0.1/project/login.php';

Can anyone tell me how can I do it?

1 Answer 1

0

Absolute URL is a good idea in ajax. Just declared var siteURL = www.example.com; globally. And used this in every ajax request like below:-

<script>
$.ajax({
    url: siteURL + '/path/to/file',
    type: 'POST',
    data: {param1: 'value1'},
});
</script>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.