Failed to upload file using jQuery ajax to targeted API
Hi,
I am failed to send a POST request using jQuery Ajax via targeted API. Please find below code,
When do a console, it straight go to failed condition.
Please help.
- var fd = new FormData();
- var files = $('#oltnpefile')[0].files[0];
- fd.append('upload_file',files);
-
- console.log(files);
- $.ajax({
- url: '/api/v1/olt/uploadfile/',
- type: 'POST',
- dataType : "json",
- data: fd,
- contentType: false,
- processData: false,
- success: function(response){
- setTimeout(function(){
- console.log(response);
-
- if(response == 0){
- $('#success-upload').modal('show');
- }else{
- alert('File Format Not Supported');
- }
- },1400);
- },
- });