• Resolved unsautenavant

    (@unsautenavant)


    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].

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi @unsautenavant,

    To answer your question, yes you can.

    Navigate to Security > Settings > Advanced > System Tweaks

    Disable (if not already) the Disable PHP in Themes setting in the PHP Execution section. Scroll to the bottom of the page and save the settings.

    +++ To prevent any confusion, I’m not SolidWP +++

    • This reply was modified 1 year, 2 months ago by nlpro.
    Thread Starter unsautenavant

    (@unsautenavant)

    Perfect, thank you very much ! That was quick ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can’t use Ajax with Solid Security ?’ is closed to new replies.