(Cross-posted from stack overflow)
I am building a WordPress plugin. The plugin works beautifully on one site.
But on every other site I've tried so far one of the resource files used it getting a 404 (Not Found) error in the console. If I post the url, displayed in the console as not found, in the address bar the file is accessible.
The site it works on is not in a root directory, while one it doesn't work on is on the same server, in the root directory and is a multisite installation. I've tried it on other servers, and sometimes it works, on others it doesn't'. I'm baffled by what might cause this... Any feedback would be appreciated.
The following code is posted using a action into the header of a page:
echo '<script type="text/javascript">
(function($){
$(document).ready(function(){
lpStart();
});
var lpOnComplete = function(response) {
// do more processing
lpStart();
};
function lpStart() {
$.post("'.plugin_dir_url(__FILE__).'filename", {varname: "'.$value.'"}, lpOnComplete, "json");
};
})(jQuery);
</script>';
The URL that is said to not exist is the one that is posted to in function lpStart().
Interestingly, when it doesn't work I get the following error in the console as the page loads.
GET http://example.com/undefined 404 (Not Found)
Thank you in advance.