Reputation: 107
I am creating a wordpress plugin and on the admin page of said plugin they fill out a form. I am using Ajax to check the ID of their entry against my DB using .load() which is resulting in a 404. I can print the file using the same file path.
I have tested the file path and "require_once(plugin_dir_path( FILE ).'assets/test.php');" prints out the file just fine. Since "wordpress", "404" & "plugin" are pretty heavy keywords its been hard to find someone with a similar issue from google.
//php on admin page
$loadURL = plugin_dir_path( __FILE__ ).'assets/test.php';
<button id="button">Load</button>
<div id="div1"></div>
// js (also on admin page)
(function($){
$(document).ready(function(){
$("#button").click(function(){
$("#div1").load("<?php echo $loadURL; ?>");
console.log( "Load was performed." );
});
});
})(jQuery);
The result is a 404 upon clicking the button. Thank you in advance for your time!
Upvotes: 0
Views: 43
Reputation: 107
I'm really dumb... I needed to use plugin_dir_url( FILE ) and not plugin_dir_path( FILE )
Upvotes: 0