Posted By

catswhocode on 08/19/17


Tagged

form ajax


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Shoora


Get all values from form and send it to a page via Ajax


 / Published in: jQuery
 

URL: https://www.catswhocode.com/blog/jquery-and-ajax-ready-to-use-code-snippets-for-every-day

Here’s a super handy snippet that I use very often. It works very simply: once the user clicks on #submit, the data from #form is serialized and sent to a remote page using the POST method.

  1. jQuery( document ).ready(function() {
  2. jQuery( "#submit" ).click(function() {
  3. jQuery.post( "https://yoursite.com/yourpage.php", jQuery('#form').serialize())
  4. .done(function( data ) {
  5. alert(data);
  6. });
  7. return false;
  8. });
  9. });

Report this snippet  

You need to login to post a comment.