Personalized checkout and custom promotions with Shopify Scripts
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' : '✓'
};
$.ajax({
url: "/account",
type: "POST",
data: customerdata,
dataType: 'json',
beforeSend: function(x) {
$('.js-customer-create').remove( $('.registration-form-errors') );
},
success: function(result) {
alert("SUCCESS:"+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) {
console.log(jqXHR);
alert("FAIL:"+textStatus+"::jqXHR:"+JSON.stringify(jqXHR)+"::Error Thrown:"+errorThrown);
console.log("jqXHR Error:"+JSON.stringify(jqXHR));
}
});
Hi @agafonec,
I am not familiar with jquery but I think you need headers on your request. Are you requesting it at the backend?
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).
By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024