Step: 1 Create a Form
<form id=”Test_form”>
Name:<input type=”text” name=”name” onsubmit=””>
Age:<input type=”text” name=”name”><br>
<div id=”result”></div>
<input type=”submit” value=”Submit” />
</form>
Step: 2 Now javascript code
<script type=”text/javascript”>
function send()
{
$.ajax({type:’POST’, url:’path_file_processing’, data:$(“#form_id”).serialize(), success:function(response){alert(response);}});
}
</script>
It will perfectly
Hi Rakesh,
For jQuery ajax calls, there’s a rather nice shorthand you can use, as well.
$.ajax({type:’POST’, url:’path_file_processing’, data:$(“#form_id”).serialize(), success:function(response){alert(response);}});
is equivalent to:
$.post(‘path_file_processing’, $(“#form_id”).serialize(), function(r){ alert(r); });
I hope that saves your keyboard some strain. Happy coding.
Thanks for your response. But this code i shows for the beginners that moves from javascript to jquery. Now are you have a solution to upload file using $(“#form_id”).serialize() . In this i want use only http://code.jquery.com/jquery-1.8.2.min.js file nothing other jquery file.
Hi. I don’t know if it can be modified to upload other data alongside the file, but I’ve had luck in the past using the iframe method to upload files with jQuery/ajax, not requiring any extra libraries:
http://stackoverflow.com/questions/7909161/jquery-iframe-file-upload
Hope this helps.