Created
May 6, 2012 04:28
-
-
Save mediaupstream/2612896 to your computer and use it in GitHub Desktop.
ajax post with jQuery
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $('#myCoolForm').submit(function(e){ | |
| e.preventDefault(); // ensures we don't actually submit the form like normal | |
| var url = $(this).attr('action'); // grabs the html form action attribute, eg our post url | |
| var data = $(this).serialize(); // this will take all the form elements and serialize them into a querystring to be posted | |
| $.post( url, data, function(data, textStatus){ | |
| // do something cool here | |
| console.log(data); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment