Failed to upload file using jQuery ajax to targeted API

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.

  1. var fd = new FormData();
  2. var files = $('#oltnpefile')[0].files[0];
  3. fd.append('upload_file',files);
  4. console.log(files);

  5. $.ajax({
  6.         url: '/api/v1/olt/uploadfile/',
  7. type: 'POST',
  8. dataType : "json",
  9.         data: fd,
  10.         contentType: false,
  11. processData: false,
  12.         success: function(response){
  13. setTimeout(function(){
  14. console.log(response);
  15.                     
  16. if(response == 0){
  17. $('#success-upload').modal('show');
  18. }else{
  19. alert('File Format Not Supported');
  20. }
  21. },1400);
  22.         },
  23. });