Ajax函数仅在调试器打开时停止

时间:2017-08-23 00:15:46

标签: php ajax wordpress woocommerce xdebug

我在woocommerce的结帐页面上有一个ajax调用,允许更改送货地址。

当我关闭xdebug时,一切都完美无瑕。 当我打开xdebug时,wp-ajax在第一个ob_start();(或第一个断点被设置的位置)停止。

JS:

  $.ajax({
    url: ajaxurl,
    type: 'post',
    data: {
        action: 'idx_update_shipping_address',
        addressId: $('input[name=is_shipping]:checked').val()
    },
    success: function (response) {
        response = JSON.parse(response);
        $(document.body).trigger('update_checkout');
        $(document.body).on('updated_checkout', function () {
            $('.shipping-address').html(response.address);
            $('.addresses-content').html(response.modal);
            $('.box-required-hidden-fields').detach();
            $('#woocommerce-checkout').append(response.hiddens);
        });
    }
});

PHP:

function idx_update_shipping_address() {
    $address_id = $_POST['addressId'];
    $address    = Address_Manager::get_address_by_id( $address_id );
    Address_Manager::set_address_to( $address, 'shipping' );

    ob_start();
    $name = 'shipping';
    include 'partials/public/checkout-formatted-address.php';
    $result['address'] = ob_get_clean();

    ob_start();
    set_values_to_array_for_required_fields( get_current_user_id(), $data_checkout );
    populate_hidden_fields_in_checkout( $data_checkout );
    $result['hiddens'] = ob_get_clean();

    ob_start();
    render_select_address( Address_Manager::get_addresses() );
    $result['modal'] = ob_get_clean();

    echo json_encode( $result );
    die;

}

任何暗示我缺少的东西? 感谢

0 个答案:

没有答案