title: Upload file and JSON data in the same POST request using jquery ajax?
body: <p>I am trying to send a POST request using jQuery Ajax, where I would like to upload a file and some json data. Please find code,</p>
  
  <pre class="lang-js prettyprint-override"><code>var logoImg = $('input[name="logoImg"]').get(0).files[0];
  var formData = new FormData();
  formData.append('logo', logoImg);
  
  var objArr = [];
  objArr.push({
    "id": id,
    "name": userName
  });
  
  var obj = [{
    "objArr": objArr,
    "formData": formData
  }];
  
  $.ajax({
    type: "POST",
    url: url,
    dataType: "json",
    data: JSON.stringify(obj),
    contentType: "application/json",
    cache: false,
    async: false,
    complete: function(data) {
      alert("success");
    }
  });
  </code></pre>
  
  <p>But I am getting <code>Internal server error: 500</code> and the backend API is not called.</p>
  
  <p>Please help me to send a file and an array obj in same AJAX request. Thanks in advance</p>