Update Customer Details
').addClass('alert alert-danger p-1 rounded-0').hide();
// Start loader
start_loader();
// **NOTE**: Update this URL to your actual customer saving script
$.ajax({
url: 'https://haragroups.co.in/classes/Master.php?f=save_customer',
method: 'POST',
data: new FormData(this), // Use FormData
processData: false,
contentType: false,
dataType: 'json',
error: function(err){
el.text('An error occurred while saving the data. Kindly refresh the page and redo your action.');
_this.prepend(el);
el.show('slideDown');
console.error(err);
end_loader();
},
success: function(resp){
end_loader();
if(resp.status === 'success'){
// **NOTE**: Update the view page URL
location.replace('https://haragroups.co.in/admin/?page=tiles/view_customer&id=' + resp.id);
} else if(resp.msg) {
// Example error handling (e.g., if WhatsApp number is duplicate)
alert(resp.msg);
if(resp.msg.includes('WhatsApp number already used')) {
$('#whatsapp_number').addClass('is-invalid').focus();
}
} else {
let message = resp.msg || 'An error occurred while saving the data.';
el.text(message);
_this.prepend(el);
el.show('slideDown');
console.error(resp);
}
}
});
});
});