I wrote an ajax call to retrieve some info to print markers on a map:

    var url_marcadores = 'http://localhost/rutaVino/wp-content/plugins/establecimientos/assets/img/';
    var url = jQuery('#mapa_general input').val();

        url: url,
        type: 'POST',
        dataType: 'JSON',
        data: {funcion: 'obtener_coordenadas_establecimientos'},
    .done(function(res) {
        var LeafIcon = L.Icon.extend({
            options: {
                iconSize:     [20, 28],
                iconAnchor:   [10, 20],
                popupAnchor:  [0, -35]

It works great but only when I'm logged in, if I visit the page as a visitor browser console shows:

XHRPOSThttps://vinos.islascanariasturismoactivo.com/wp-content/plugins/establecimientos/inc/base/establecimientos-main.php [HTTP/2 406 Not Acceptable 207ms]

Don't know what can be happening

  • How are you adding your AJAX code to WordPress? What hooks are you using? – Pat J Aug 21 at 21:51
  • I'm using it directly on a js file I added inside my plugin – ominem Aug 22 at 10:55
  • If you are using WP hooks for ajax call back function in php. Just make sure you have added like wp_ajax_nopriv_youraction. – Pradipta Sarkar Aug 22 at 15:47
  • I wasn't using any hooks, I updated my code to work with admin-ajax and the hooks you mention (wp_ajax_nopriv,wp_ajax_) and now it works. Thank you – ominem Aug 22 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.