Javascript 监视JQuery在WooCommerce上发出的所有AJAX请求
有没有一种方法可以监视在WooCommerce上使用JQuery发出的所有Ajax请求Javascript 监视JQuery在WooCommerce上发出的所有AJAX请求,javascript,jquery,ajax,wordpress,woocommerce,Javascript,Jquery,Ajax,Wordpress,Woocommerce,有没有一种方法可以监视在WooCommerce上使用JQuery发出的所有Ajax请求 我试图检测WooCommerce购物车页面上的哪个Ajax事件有时会在我的WordPress网站上引起无限循环。您可以尝试jquery本身提供的ajaxstart事件。Jquery在发送任何ajax请求时都会触发此事件 $( document ).ajaxStart(function() { $( "#loading" ).show(); }); #希望这对您有所帮助,谢谢。您可以尝
我试图检测WooCommerce购物车页面上的哪个Ajax事件有时会在我的WordPress网站上引起无限循环。您可以尝试jquery本身提供的ajaxstart事件。Jquery在发送任何ajax请求时都会触发此事件
$( document ).ajaxStart(function() {
$( "#loading" ).show();
});
#希望这对您有所帮助,谢谢。您可以尝试jquery本身提供的ajaxstart事件。Jquery在发送任何ajax请求时都会触发此事件
$( document ).ajaxStart(function() {
$( "#loading" ).show();
});
#希望这对您有所帮助,谢谢。您可以使用:
,用于在发送Ajax请求之前附加要执行的函数ajaxSend()
,它注册一个处理程序,在Ajax请求完成时调用ajaxComplete()
add_action( 'wp_footer', 'monitor_jquery_ajax_requests' );
function monitor_jquery_ajax_requests() {
?>
<script>
jQuery(document).ajaxSend( function( event, xhr, options ) {
console.log('------- ' + event.type + ' -------');
console.log(xhr);
console.log('------------------------');
}).ajaxComplete( function( event, xhr, options ) {
console.log('----- ' + event.type + ' -----');
console.log(xhr);
console.log('----------------------------');
});
</script>
<?php
}
add_操作('wp_footer'、'monitor_jquery_ajax_requests');
函数监视器\u jquery\u ajax\u请求(){
?>
jQuery(文档).ajaxSend(函数(事件、xhr、选项){
console.log('----'+event.type+'----');
console.log(xhr);
console.log('---------------------------');
}).ajaxComplete(功能(事件、xhr、选项){
console.log('----'+event.type+'----');
console.log(xhr);
console.log('--------------------------------------');
});
您可以使用:
ajaxSend()
,用于在发送Ajax请求之前附加要执行的函数
ajaxComplete()
,它注册一个处理程序,在Ajax请求完成时调用
两者都提供了与在浏览器Javascript控制台中可读的XHR对象上触发的Ajax事件相关的详细信息
下面是一个显示Ajax触发的请求详细信息的代码示例:
add_action( 'wp_footer', 'monitor_jquery_ajax_requests' );
function monitor_jquery_ajax_requests() {
?>
<script>
jQuery(document).ajaxSend( function( event, xhr, options ) {
console.log('------- ' + event.type + ' -------');
console.log(xhr);
console.log('------------------------');
}).ajaxComplete( function( event, xhr, options ) {
console.log('----- ' + event.type + ' -----');
console.log(xhr);
console.log('----------------------------');
});
</script>
<?php
}
add_操作('wp_footer'、'monitor_jquery_ajax_requests');
函数监视器\u jquery\u ajax\u请求(){
?>
jQuery(文档).ajaxSend(函数(事件、xhr、选项){
console.log('----'+event.type+'----');
console.log(xhr);
console.log('---------------------------');
}).ajaxComplete(功能(事件、xhr、选项){
console.log('----'+event.type+'----');
console.log(xhr);
console.log('--------------------------------------');
});
我得了新冠肺炎,我住院了,在医院工作,真是疯了!但你是个传奇!我得了新冠肺炎,我住院了,在医院工作,真是疯了!但你是个传奇!