jqueryajaxfunction-binding

404 error when binding named function with jQuery ajax inside


Doing an ajax request when click button works fine, return as expected. But the problem is when I try to bind a function to an element with an ajax request inside.

The function give me 404 error on this url, but the file exist (same server, same domain...)

jQuery(function() {
    jQuery('.searcher-rooms .button').click(function() {
        var n = jQuery.now(),
            l = jQuery('.town-list').val(),
            c = jQuery('.short-hotel-list').val();
        if (l == null) {
            l = 'all';
        };
        if (c == null) {
            c = 'all-hotels';
        };
        if (l != '' && l != 'all' && l != 'current') {
            n += '&l='+l;
        };
        if (c != '' && c != 'all-hotels') {
            n += '&c='+c;
        };
        jQuery.ajax({
            url: theme.child_theme_uri+'/searcher.php?t='+n,
            type: 'GET',
            beforeSend: function() {
                jQuery('#data-wrapper').addClass('loading');
            }
        }).done(function(data) {
            jQuery('#data-wrapper').html(data).attr('data-time', n.toString().split('&')[0]).attr('data-location', l).attr('data-hotel', c);
            jQuery('#data-wrapper').removeClass('loading');
            jQuery('.load-more-hotels').bind('click', d_more_hotels);
        })
    })
});

function d_more_hotels() {
    var e = jQuery('#data-wrapper'),
        t = e.attr('data-time'),
        l = e.attr('data-location'),
        c = e.attr('data-hotel'),
        w = jQuery('.load-more-hotels').attr('data-page');
    jQuery.ajax({
        url: theme.child_theme_uri+'/searcher.php?t='+t+'&l='+l+'&c='+c+'&w='+w,
        type: 'GET',
        beforeSend: function() {
            jQuery('#data-wrapper').addClass('loading');
        }
    }).done(function(data) {
        jQuery('#data-wrapper').html(data)
        jQuery('#data-wrapper').removeClass('loading');
        jQuery('.load-more-hotels').attr('data-page', parseInt(w)+1).unbind().bind('click', d_more_hotels);
    })
}

jQuery.ajax function inside "d_more_hotels" function give a 404 error in url, but the file exists.

I've checked all variables and doing a log to see full url param used, but all seems ok.

Working under WordPress last version framework.

:S

Any help is apreciated.

EDIT:

Solution found here https://stackoverflow.com/a/3445620/3676282

WordPress function mess


Solution

  • Solution found here https://stackoverflow.com/a/3445620/3676282

    404 error fired due to Wordpress security