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


/ Published in: jQuery
Save to your folder(s)

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.


Copy this code and paste it in your HTML
  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. });

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

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.