Is Ajax in WordPress

后端 未结 7 1053
萌比男神i
萌比男神i 2021-01-03 17:23

Is there anyway to detect if the current server operation is currently an AJAX request in WordPress?

For example:

is_ajax()
7条回答
  •  滥情空心
    2021-01-03 18:20

    I personally prefer the wp_doing_ajax(), but here is another example that should do it.

    if( true === strpos( $_SERVER[ 'REQUEST_URI' ], 'wp-admin/admin-ajax.php' ) ) {
        // is doing ajax
    }
    

提交回复
热议问题