クリックボタンが正常に機能するときに ajax リクエストを実行すると、期待どおりに戻ります。しかし、問題は、内部に ajax リクエストを含む要素に関数をバインドしようとしたときです。
関数はこのURLで404エラーを返しますが、ファイルは存在します(同じサーバー、同じドメイン...)
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);
})
}
「d_more_hotels」関数内の jQuery.ajax 関数は URL で 404 エラーを返しますが、ファイルは存在します。
すべての変数をチェックし、ログを作成して完全な URL パラメータが使用されていることを確認しましたが、すべて問題ないようです。
WordPress の最終バージョンのフレームワークで作業しています。
:S
どんな助けでも大歓迎です。
編集:
ここに解決策がありますhttps://stackoverflow.com/a/3445620/3676282
WordPress機能の混乱