-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
40 lines (29 loc) · 952 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
$('body').off('submit', '#form').on('submit', '#form', function (e) {
e.preventDefault(); // Prevent default form submission behavior
// defautl settings
$formData = new FormData();
$formData.append('fileToUpload', $('#formFile')[0].files[0]);
var data = $('#form').serializeArray();
// console.log(data)
var formdata = $("#form").serializeArray();
$(formdata).each(function (index, obj) {
$formData.append(obj.name,obj.value);
});
$.ajax({
type: 'POST',
url: 'backend.php',
data: $formData,
processData: false,
contentType: false,
dataType: 'text',
success: function (response) {
// Handle successful response
console.log(response);
$('#proccessData').text(response);
},
error: function (xhr, status, error) {
// Handle errors
console.error('Error:', error);
}
});
});