js file in content/themes/themename/js/main.js
in this file I am trying to do an ajax call to this file content/themes/themename/lib/file.php
this is how my ajax call looks like
$.ajax({
type: 'POST',
url: 'file.php',
success: function(result) {
var data = jQuery.parseJSON(result);
console.log(data.name);
}
});
but the url is not working anyone can help me out?
I have tried ../lib/file.php too
maybe you can try with the path that relative to the root directory
ex :
I fixed it by doing this in my body tag of my header.php file
and use the url in my javascript like this