AJAX create form. 406 error on form submit.

1 0 0

Hi Everyone, i have a problem with my code, don't understand where. when trying to send the ajax request to create an account i get 406 error. can somebody help with this? Thanks in advance.

        var customerdata = {
            'customer[email]': "dev@astraverdes.com",
            'customer[password]': "12345",
            'customer[first_name]': "Dan",
            'customer[last_name]': "Test",
            'form_type': 'create_customer',
            'utf8' : '✓'
            url: "/account",
            type: "POST",
            data: customerdata,
            dataType: 'json',
            beforeSend: function(x) {
                $('.js-customer-create').remove( $('.registration-form-errors') );

            success: function(result) {

                $('.js-customer-create').prepend(`<ul class="registration-form-success">Thank You, account has been successfully created.</ul>`);

                // window.location.href = "/account";
            }, error: function(jqXHR, textStatus, errorThrown) {
                alert("FAIL:"+textStatus+"::jqXHR:"+JSON.stringify(jqXHR)+"::Error Thrown:"+errorThrown);
                console.log("jqXHR Error:"+JSON.stringify(jqXHR));
Replies 2 (2)

Shopify Partner
3806 713 1129

Hi @agafonec,


I am not familiar with jquery but I think you need headers on your request. Are you requesting it at the backend?

Volunteering to assist you!  Likes and Accept as Solution  is highly appreciated.✌
Coffee fuels my dedication. If helpful, a small Coffee Tip would be greatly appreciated.
Need EXPERIENCED Shopify developer without breaking the bank?
Hire us at Made4Uo.com for quick replies.
Stay in control and maintain your security by avoiding unnecessary store access!

Shopify Partner
3 0 0

I think it's a bad solution to create a client. To do this, you can use the Storefront API. Use mutation customerCreate (https://shopify.dev/api/storefront/2022-04/mutations/customerCreate).

Shopify developer