Can’t use Ajax with Solid Security ?

[ad_1]

Hello,

I’ve found a problem on my website. In an administration page that I made, I’m trying to do an Ajax resquest but it seems that Solid Security block it.

The resquest works well with Solid Security disabled or with Workfence. But I have a 403 Forbidden error on the console when I try to access to a different file

Here is my code :

jQuery(document).ready(function($) {
$("#tirage_gagnant").submit(function(e) {
e.preventDefault(); // Empêche le formulaire de se soumettre normalement

var formData = $(this).serialize(); // Récupère les données du formulaire

// console.log(formData);

$.ajax({
type: "POST",
url: "/wp-content/themes/mytheme/myfile.php", 
data: formData,
beforeSend: function() {
$("#liste_resultats").html("Chargement en cours...");
},
success: function(response) {
$("#titre_resultats").html('<h2>Liste des personnes</h2>');
$("#liste_resultats").html(response); 
},
error: function(xhr, textStatus, errorThrown) {
alert("Une erreur s'est produite lors de l'envoi des données.");
}
});
});
});

I’ve got the alert showing when I’m sending the request, and the console show me this :

POST https://mywebsite.fr/wp-content/themes/mytheme/myfile.php 403 (Forbidden)
send @ load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils&ver=6.4.2:2
ajax @ load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils&ver=6.4.2:2
(anonymous) @ load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils&ver=6.4.2:5
e. @ load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils&ver=6.4.2:5
(anonymous) @ admin.php?page=tirage-au-sort:249
dispatch @ load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils&ver=6.4.2:2
v.handle @ load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,jquery-migrate,utils&ver=6.4.2:2

What can I do to allow ajax on my website (at least in the administration part…) ?

Thanks !

[Edit : XML-RPC is activated, the checkbox “Allow multiple authentication attempts via XML-RPC” is checked and “Default block list” is unchecked].

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer