I have the following form in my PHP file defined. I am planning to convert the form fields to JSON object so that I could pass it along to a java webservice using Ajax maybe.
Here's how I was planning to serialize it :
function submitUsingjQuery(){
var formdata = $('#myForm').serializeArray()
}
Since I have three files upload options, is it possible to convert uploaded files to a JSON object as well along with other form fields? If not, is there any other alternative to achieve this ?
<!-- Start of HTML Form -->
<form id = "myForm">
<div class="row" style="margin-bottom: 15px" name="infoRegAttachedDocuments" >
<div class="col-md-4">
<label for="docSubmission">First Document</label>
<input type="file" id="firstdoc">
</div>
<div class="col-md-4">
<label for="docApproval">Second Document</label>
<input type="file" id="seconddoc">
</div>
<div class="col-md-4">
<label for="additionalDocs">Third Document (if any)?</label>
<input type="file" id="thirdocs">
</div>
</div>
<div class="row" style="margin-bottom: 15px" name="infoDiv" >
<div class="col-md-6">
<label for="projectTitle">Title </label>
<input type="text" class="form-control" id="projectTitle" value="<?php echo $previousProjTitle;?>" >
</div>
<div class="col-md-6">
<label for="projectDesc">Description </label>
<input type="text" class="form-control" id="projectDesc" value="<?php echo $previousProjDesc;?>">
</div>
</div>
</form>
<!-- END of HTML Form -->
<div class="row"style="margin-top: 15px;" >
<button class="btn btn-primary" onclick="submitUsingjQuery()">Submit</button>
</div>