I'm very new to Ajax and PHP. I'm using below code to submit my HTML form via Ajax but image files aren't passed through. I tried adding contentType in the code still no luck. Please help can I use the same code (with tweaks) to submit the image files along with text inputs?
Here is the code:
$(document).ready(function() {
$("#submit_form").submit(function() {
$.ajax({
type: "POST",
url: 'inc/submit_form.php',
data:$("#submit_form").serialize(),
success: function (data) {
// Inserting html into the result div on success
$('#form-result').html(data);
},
error: function(jqXHR, text, error){
// Displaying if there are any errors
$('#form-result').html(error);
}
});
return false;
});
});