I want to submit two different forms with AJAX, but I am unable to identify how to select these forms for making form data object (it has files as well ). I have tried this for one form:
<form class="ui form" id="contact-form" enctype="multipart/form-data" onsubmit='return !!(filecheck() && show());'>
<div class="field">
<label>Title of the Ad</label>
<input name="title" type="text" id="title">
</div>
<div class="field">
<label>Select Car Make</label>
</form>
$("#contact-form").submit(function(e){
e.preventDefault();
var form = $('form')[0];
var formData = new FormData(form);
$.ajax({
url: 'infocheck.php',
async: true,
cache: false,
data: formData,
contentType: false,
processData: false, //
type:'post',
success: function(response) {
document.getElementById("loader").style.display = "none";
alert(response);
}
});
});
Now I have another form
<form class="ui form" id="second-form" enctype="multipart/form-data" onsubmit='return !!(filecheck() && show());'>
<div class="field">
<label>Title of the Ad</label>
<input name="title" type="text" id="title">
</div>
<div class="field">
<label>Select Car Make</label>
</form>
How to send request for this form as well ...any idea?