I am creating a plugin in wordpress that needs an AJAX call. The call goes through, but I get a 403.
I've gone through tutorials and checked other plugin codes and can't figure out why it's not working. Apparently all my enqueues are OK.
This is my main.php plugin code:
function launchRecommender(){
wp_enqueue_style( 'ai-plugin-css', plugin_dir_url( __FILE__ ) . 'css/style.css');
wp_enqueue_script('ai-plugin-js', plugin_dir_url( __FILE__ ). 'js/index.js', array( 'jquery' ));
wp_localize_script('ai-plugin-js', 'ia', array(
'pluginsUrl' => plugins_url()
));
include('includes/recommender.php');
}
add_shortcode('recomendador', 'launchRecommender');
And this is the JS code that after being executed receives the 403 error:
jQuery.ajax({
type: "POST",
url: ia.pluginsUrl + "/plugin-name/includes/process.php",
data: {student_email:'ex@ex.com'},
action: "",
success: function(xml) {
console.log(xml)
},
error: function(e){
console.log(e)
}
})
Do I need an additional hook? Is the url badly managed?