I'll keep this short and sweet, I want to load a JS file in the admin panel as part of my plugin, and through tons of research I have a few different options that have all ended with the same problem that no one else seems to be experiencing so finally I'm posting for a solution here.
When I use the following code I get an error:
function register_scripts(){
wp_register_script('payee',plugins_url('iBudget/modules/payee/payee.js',__FILE__));
}
function payee_init($hook){
wp_enqueue_script('payee');
}
add_action ("admin_print_styles-post.php", "payee_init");
add_action ("admin_init", "register_scripts");
ERROR: /wp-content/plugins/iBudget/modules/payee/iBudget/modules/payee/payee.js/?ver=3.3.1:1 Uncaught SyntaxError: Unexpected token <
No matter how I attempt to enqueue the scrip I get this error even though the JS file simple says: alert("test");
Now the interesting nugget is this, if I include the JS directly in the function everything works fine:
function payee_init($hook){
?>
<script>
alert("test");
</script>
<?
}
add_action ("admin_print_styles-post.php", "payee_init");
Basically I need to know why this error is coming up, I believe I'm loading the script correctly for what I need but not sure why this conflict is there and not even sure where else to look for a solution.
Thanks guys!