first commit
This commit is contained in:
53
public/themes/tailwind/js/cms/companies/show-xero-api.js
Normal file
53
public/themes/tailwind/js/cms/companies/show-xero-api.js
Normal file
@@ -0,0 +1,53 @@
|
||||
$(document).ready( function () {
|
||||
$.ajaxSetup({
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
||||
}
|
||||
});
|
||||
|
||||
$('#updateXeroApiFrm').submit(function(e) {
|
||||
e.preventDefault();
|
||||
var action = $(this).attr('action');
|
||||
var button = $(this).find('button[type="submit"]');
|
||||
var buttonHtml = button.html();
|
||||
|
||||
if (!button.is(':disabled') && action) {
|
||||
button.attr('disabled', 'disabled');
|
||||
button.html('<i class="fa fa-spinner fa-spin" style="font-size:24px"></i>');
|
||||
|
||||
$.ajax({
|
||||
url: action,
|
||||
type: "post",
|
||||
data: $(this).serialize(),
|
||||
dataType: 'json',
|
||||
success:function(data) {
|
||||
button.removeAttr('disabled');
|
||||
button.html(buttonHtml);
|
||||
|
||||
if (data.success) {
|
||||
$('#validationModal').modal('show');
|
||||
$('#validationModal .error-message').html(data.message);
|
||||
}
|
||||
else {
|
||||
$('#validationModal .error-message').html(data.message);
|
||||
$('#validationModal').modal('show');
|
||||
}
|
||||
},
|
||||
error: function(data) {
|
||||
var errors = data.responseJSON.errors;
|
||||
var errorMessage = '<ul>';
|
||||
$.each(errors, function(index, error) {
|
||||
console.log(error);
|
||||
errorMessage += '<li>' + error[0] + '</li>';
|
||||
});
|
||||
errorMessage += '</ul>';
|
||||
|
||||
$('#validationModal .error-message').html(errorMessage);
|
||||
$('#validationModal').modal('show');
|
||||
button.removeAttr('disabled');
|
||||
button.html(buttonHtml);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
} );
|
||||
Reference in New Issue
Block a user