通过ajax定制注册表格

时间:2018-10-05 09:07:59

标签: jquery ajax wordpress woocommerce registration

原谅我再次将自己托付给社区,但我在黑暗中摸索。

在结帐时,相同的逻辑对我有用,但在此处是注册号。

    in my custom "https://woo/account/"

  <?php if ( !is_user_logged_in() ) { ?>

    <div class="registration-form woocommerce" >
        <form id="register-form" class="woocommerce-form woocommerce-form-login login">

            <?php do_action( 'woocommerce_register_form_start' ); ?>

                my bal bla form fields for registration

            <?php do_action( 'woocommerce_register_form_end' ); ?>

        </form>
    </div>

  <?php  } elseif (is_user_logged_in()) { ?>
    show the profile
  <?php }   ?>

臭名昭著的没有注册。 它可以直接工作,但在ajax中不行:

$('#register-form').submit(function()
{

    alert("test: ok it's active...")

    var theForm = $(this);

    //var theurl = "<?php echo admin_url('admin-ajax.php'); ?>";
    //var theurl = "http://localhost/woocommerce/wp-json/wp-json/sow/v1/regist_user";
    //var theurl = "http://localhost/woocommerce/wp-login.php/?action=register";
    var theurl = "http://localhost/woocommerce/wp-login.php?action=register";

    theForm.find("input[type='submit']").addClass("loadinganimation").html("standby - controllo in corso...").attr("disabled",true).addClass("disabled");


    $.ajax({
        type:"POST",
        url: theurl,
        dataType: 'json',
        data: theForm.serialize(),
        success: function(data)
        {
            alert('sanding data...');
        }

    })
    .fail(function()
    {

        alert( "DAMN! ERROR." );
        theForm.find("input[type='submit']").addClass("erroranimation").html("errore riscontrato - contatta l'admin").attr("disabled",true).addClass("disabled");

    })
    .done(function()
    {

        theForm.find("input[type='submit']").removeClass("passedanimation").attr("disabled",true).removeClass("disabled");

        setTimeout(function()
        {
            alert("It's ok, refresh page and see profile");
            location.reload();

        },2000);

    });

    // prevent submitting again
    return false;

});

我在做什么错了?

有人可以帮助我理解吗?

0 个答案:

没有答案