Post a form field using jquery

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

Advertisements

3 thoughts on “Post a form field using jquery

  1. 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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s