<form id="myForm" method ="post" enctype="multipart/form-data"> First Name: <input type="text" name="fname" id="fname" /> <br> Last Name: <input type="text" name="lname" id="lname" /> <br> Email: <input type="text" name="email" id="email" /> <br> Image: <input type="file" name="image" id="image" /> <br> <button type="button" name="btnSubmit" id="btnSubmit"> Submit </button> </form>
<script language="javascript" src="js/jquery-1.9.1.min.js"></script> <script language="javascript" src="js/jquery.form.js"></script> <script type="text/javascript"> $(document).ready(function(){ //alert(4); $("#btnSubmit").click(function(){ var formData = new FormData($("#myForm")); alert(formData); console.log(formData); $.ajax({ type: 'POST', url: 'learn_form2.php', data: formData, success: function (data) { alert(data); }, cache: false, contentType: false, processData: false }); }); }); </script>
<?php echo $_REQUEST['fname']; ?>
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)