Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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)
          }
      })

})
Comment

PREVIOUS NEXT
Code Example
Javascript :: discord.js 
Javascript :: javascript websocket example code 
Javascript :: disable button 
Javascript :: promise.race polyfill 
Javascript :: multithreading in javascript 
Javascript :: get url query in react 
Javascript :: safeAreaProvider 
Javascript :: text overflow ellipsis two lines react native 
Javascript :: disable button based on condition angular 
Javascript :: Conflicting peer dependency: react@18.0.0 npm WARN node_modules/react 
Javascript :: How to print somethign to the console with javascript 
Javascript :: for of loop js 
Javascript :: redirect after print javascript 
Javascript :: unix to date in javascript 
Javascript :: date difference moment js 
Javascript :: js debouncing 
Javascript :: How to set the background image URL of an element using jQuery 
Javascript :: javascript fromEntries 
Javascript :: javascript show page 
Javascript :: new line in javascript alert 
Javascript :: pass multi variable in ajax 
Javascript :: select a particular sibling jquey 
Javascript :: next js build command 
Javascript :: how to give width through props 
Javascript :: javascript test is not a function 
Javascript :: exist element js 
Javascript :: object literal javascript 
Javascript :: “https://packagist.org/packages.json” file could not be downloaded: failed to open stream: Operation timed out 
Javascript :: find object in json array 
Javascript :: resize array javascript 
ADD CONTENT
Topic
Content
Source link
Name
8+7 =