Uploading both data and files in one form using ajax

Solution founded for: Sending image and input data in single ajax call, Image and text data in ajax post, Uploading both data and files in one form using ajax, jQuery ajax multipart form with $_FILES and $_POST, $_FILES and $_POST using ajax and jQuery ajax image upload.

Answer for above all question is jQuery Form Plugin. I am searching solution of above questions for 5-6 days and finally found amazing plugin for it. Simple demo code for test plugin is given below.

jQuery Plugin
jQuery Plugin

HTML Code:

<html>   
 <head>   
   <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script>   
   <script src="http://malsup.github.com/jquery.form.js"></script>      
   <script>   
     $(document).ready(function(){  
       //SET YOUR AJAX OPTION  
       var options = {   
          target: '#output1',  
          beforeSubmit: function(formData, jqForm, options){  
              //CODE BEFORE AJAX REQ SEND  
          },  
          success: function(responseText, statusText, xhr, $form){  
              //CODE FOR AJAX REQ SUCCESS  
          }  
       };   
               
       //FIRE AJAX FORM SUBMIT AFTER APPLYING VALIDATION, IF ANY
       //HERE NO VALIDATION CHECKED BELOW CODE FIRE DIRECTLY ON FORM SUBMIT
       //IF YOU WANT TO USE VALIDATION ADD BELOW CODE IN VALIDATION SUCCESS BLOCK 
       $('#myForm').ajaxForm(options);   
     });   
   </script>   
 </head>  
 <body>  
 
 <form id="myForm" action="test.php" method="post">   
 Firstname: <input type="text" name="firstname" /><br/><br/>  
 Lastname: <input type="text" name="lastname" /><br/><br/>      
 Image: <input type="file" name="photo" /><br/><br/>  
 <input type="submit" name="dataAndImageForm" value="Submit form" />   
 </form>  
 
 <span>Output From Server:</span><br/>  
 <div id="output1"></div>  
 </body>  
</html>

PHP Code: (test.php)

<?php  
 
 if(isset($_POST['dataAndImageForm']))  
 {      
     echo '<pre>';  
     print_r($_POST);  
     print_r($_FILES);  
     echo '<pre>';  
     exit;  
 }  

?>

For more info and example:
For more info and example visit jQuery Form Plugin.