Upload file and JSON data in the same POST request using jquery ajax?

Upload file and JSON data in the same POST request using jquery ajax?

Hi, 
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 below 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");
                }
});


But I am getting "Internal server error: 500" and the backend API is not called.

Please help me to send a file and an array obj in same AJAX request. Thanks in advance