Fix home page upload to use json api instead of seperate upload code
This commit is contained in:
parent
00b0687136
commit
a097db2017
6 changed files with 27 additions and 115 deletions
|
@ -4,14 +4,29 @@ $(function() {
|
|||
event.stopPropagation();
|
||||
|
||||
// Create new form data object with the contents of this form
|
||||
var formData = new FormData(this);
|
||||
var formData = new FormData();
|
||||
formData.append('file', $('#tran-file')[0].files[0]);
|
||||
formData.append('json', JSON.stringify({
|
||||
transaction_type: $('#tran-type').val(),
|
||||
organisation_name: $('#org-name').val(),
|
||||
street_name: $('#org-street').val(),
|
||||
town: $('#org-town').val(),
|
||||
postcode: $('#org-postcode').val(),
|
||||
transaction_value: $('#tran-value').val()
|
||||
}));
|
||||
|
||||
$.ajax({
|
||||
url: $(this).attr("action"),
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
success: function(data) {
|
||||
alert(data);
|
||||
console.log(data);
|
||||
alert(data.message);
|
||||
$('form#receipt-form')[0].reset();
|
||||
},
|
||||
error: function(data) {
|
||||
console.log(data);
|
||||
alert(data.responseJSON.message);
|
||||
},
|
||||
cache: false,
|
||||
contentType: false,
|
||||
|
|
Reference in a new issue