【问题标题】:ajax and woocommerce page loaded twiceajax 和 woocommerce 页面加载了两次
【发布时间】:2019-09-06 18:49:10
【问题描述】:
    add_action( 'admin_menu', array($this, 'admin_menu'), 100 );

public function admin_menu() {
    $page = add_submenu_page( 'edit.php?post_type=product', __( 'ajaxmain' ), __( 'ajaxmainagain' ), apply_filters( 'woocommerce_csv_product_role', 'manage_woocommerce' ), 'ajaxmain-product', array( $this, 'output' ) );
}

public function output() {
    include( 'ajaxmain.php' );
}

当我使用上面的代码时: ajaxmain.php 被加载了 2 次。 然后ajaxmain.php 也不起作用。 可能是因为现在有两个元素具有相同的 id。 实际上,有些元素发出 ajax 请求,而有些元素不发出 ajax 请求。

感谢您的帮助

【问题讨论】:

    标签: php ajax woocommerce


    【解决方案1】:

    页面现在没有加载两次。 我有一个基类和一个继承类。 我试图实例化这两个类,我的add_action( 'admin_menu', array($this, 'admin_menu'), 100 ); 在基类的constructor 中。 因此页面被加载了两次。

    但是页面的单次加载不适用于 ajax。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-02-24
      • 2011-02-04
      • 2013-08-17
      • 2021-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多