Flickr Gallery

Submit Html Form With Ajax Or Jquery

We Have Two Type Of Html Form Submission :

1. Using PHP Where Form Submitted & Page Having Reload or Redirected To Thired Page.

2. Ajax Form Submitted Or Run Time Form Submitted Through Ajax Without Page Reload or Redirected.

Download js File For Use Jquery/Ajax in HTML/PHP Page 

Directory Structure  

root
  •    index.html/index.php
  •    process.php

HTML Form Sent By Ajax Method is Working Same as work in PHP

index.php or index.html (as you want)
<html>
<body>
<form id="form1">
<input type="text" name=""/>
<input type="file" name=""/>
<input type="submit" name="" id="submit"/>
</form>
</body>
</html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script>
$("#submit").click(function(){
var formdata = new FormData($("#form1")[0]);
$.ajax({
url: process.php,
type: "POST",
data: formdata,
success: function(response){
console.log(response);
},
contentType: false,
cache: false,
processData:false
});
});
</script>
process.php
<?php
             print_r($_POST);
             print_r($_FILE);
?>
Share on Google Plus

About Unknown

This is a short description in the author block about the author. You edit it by entering text in the "Biographical Info" field in the user admin panel.
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment