Plugin use of ajax/jquery depending dropdown

Question

i am looking for an example on which implements two depending dropdowns. There are a zillion examples on the internet but they are not working within wordpress plugin. So this is what if have

In the JS File

    $('#am_organisation').change(function(){
        var val =  $(this).val();
         
        $.ajax({
            type: 'POST',
            url: 'reuse/get-contacts.php',
            data:'organisation_id='+val,
            success: function(data){
                $("#am_contact").html(data);
                //$("#loader").hide();
            },
            error: function(xhr, status, error) {
                alert(xhr.responseText);
              }
                    
            });
    });```

for some reason it cannot find the URL php file get-contacts.php. It is located in a subfolder folder from the page file

mypage.php
/reuse/get-contacts/php
/js/myjavascript.js

I have tried tgo put them all in the same folder, Changed the folder with ./ or ../../ or just / Nothing seems to work.

SO i am in a wordpress plugin. On mypage i have two dropdowns from which the second one should filtered data based on the selection of the first one. How do i managed this in a wordpress plugin.

Thanks for your time, marcel

0
, , , Marcel Vreuls 5 months 0 Answers 96 views 0

Leave an answer