Site icon Hip-Hop Website Design and Development

Points calling relaxation api from a customized plugin javascript

So, I’ve a customized plugin I am engaged on for a WordPress website. I must make an ajax name when a button is clicked. However after I make the decision, nothing occurs. To date I received this:

  1. I’ve already registered the remainder route like this on the plugin php file:

    register_rest_route( $base_path, ‘/agencias-all/’, array(
    ‘strategies’ => ‘GET’,
    ‘callback’ => array( $this, ‘get_agencias_all_sorted’ ),
    ));

  2. Obtained this code on the plugin primary js file (which is already enqueued, and the operate is out there for me on the entrance finish)

    operate getAgenciasSorted(){
    $("#agencias").addClass("loading");
    console.log(‘take a look at’);

    $.get(mypath + ‘agencias-all’).achieved( response =>{
    console.log(‘take a look at 1’);
    console.log(response);
    }).full( ()=>{
    $("#agencias").removeClass("loading");
    })
    }

And I am at misplaced right here. The operate runs, the console exhibits the primary log "test". However would not exhibits the second log of "test 1" nor the response. However what’s bizarre is that if I’m going to the community tabs within the dev instruments, and search for the get_all name, it is there, and it exhibits the response there. Nevertheless, for some purpose, it isn’t operating any code contained in the .achieved

The remainder of the api calls are run whereas the web page hundreds, and people work tremendous. I am simply struggling to get this one particularly working. Any ideas or assist could be strongly appreciated, as I am simply beginning to work with customized plugins.