upload excel file using jquery ajax

Solutions on MaxInterview for upload excel file using jquery ajax by the best coders in the world

showing results for - "upload excel file using jquery ajax"
Eric
02 May 2020
1$('#input-file').change(function() {
2
3      var url = '/back-end-url';
4      var form_data = new FormData();
5      var xhr = new XMLHttpRequest();
6
7      $.each(this.files, function (key, value) {
8          form_data.append('file', value)
9      })
10
11      xhr.open('POST', url, true)
12      xhr.setRequestHeader("X-Requested-With", "XMLHttpRequest")
13      xhr.send(form_data)
14
15      xhr.onreadystatechange(function() {
16          if(xhr.readyState == XMLHttpRequest.DONE) {
17               var res = JSON.parse(xhr.responseText)
18          }
19      })
20
21})
22