I want to make an ajax call that sends both JSON and file data to my PHP backend. This is my ajax call currently:
$.ajax({
type: 'POST',
dataType: 'json',
data: jsonData,
url: 'xxx.php',
cache: false,
success: function(data) {
//removed for example
}
});
The data(jsonData) is a JSON array that also holds the input from a file select as well(I am assuming this is wrong due to the type mismatch). I tried using contentType: false
, and processData: false
, but when I try to access $_POST
data in PHP there is nothing there. The data I am passing does not come from a form and there is quite a bit of it so I do not want to use FormData
and append it to that object. I am hoping i will not have to make two ajax calls to accomplish this.