-1

Following is my JQuery script code in the body tag.

<script type="text/javascript">
    $("#submit-data").click(function()
        {
            var form = new FormData($('#patient-personal')[0]);
            console.log(form);
        });
</script>

Following is my HTML code:

<form id="patient-personal" onsubmit="return false;" role="form">
<div class="form-body">
    <div class="row">
        {{-- Form Start --}}
        {{-- First Name --}}
        <div class="col-md-4">
            <div class="form-group form-md-line-input form-md-floating-label">
                <input type="text" class="form-control" name="firstname" id="firstname">
                <label for="firstname">First Name</label>
                <span class="help-block">Patient's First Name</span>
            </div>
        </div>
        {{-- Last Name --}}
        <div class="col-md-4">
            <div class="form-group form-md-line-input form-md-floating-label">
                <input type="text" class="form-control" name="lastname" id="lastname">
                <label for="lastname">Last Name</label>
                <span class="help-block">Patient's Last Name</span>
            </div>
        </div>
        {{-- Date of Birth --}}
        <div class="col-md-4">
            <div class="form-group form-md-line-input form-md-floating-label">
                <input type="date" class="form-control" name="dob" id="dob">
                {{-- <label for="dob">Date of Birth</label> --}}
                <span class="help-block">Patient's Date of Birth</span>
            </div>
        </div>
    </div>
</div>
<a href="javascript:;" id="submit-data" class="btn green button-submit"> Submit</a>
</form>

When ever i click on the submit button it shows no values in the Form variable. It shows a blank array. What may be the reason behind it?

Akshay Shrivastav
  • 1,115
  • 4
  • 17
  • 43

1 Answers1

-2

Try this snip:

$('#patient-personal').serialize();
TomServo
  • 7,248
  • 5
  • 30
  • 47
Niranjan
  • 47
  • 2
  • 7