upload excel file using jquery ajax
$('#input-file').change(function() {
var url = '/back-end-url';
var form_data = new FormData();
var xhr = new XMLHttpRequest();
$.each(this.files, function (key, value) {
form_data.append('file', value)
})
xhr.open('POST', url, true)
xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest")
xhr.send(form_data)
xhr.onreadystatechange(function() {
if(xhr.readyState == XMLHttpRequest.DONE) {
var res = JSON.parse(xhr.responseText)
}
})
})