Forked from anonymous/FreeCourseGuideAjax.html
Last active
December 22, 2015 17:59
-
-
Save CVertex/6509828 to your computer and use it in GitHub Desktop.
This file contains 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
<form action="#" id="courseGuideForm" method="post"> | |
<input type="hidden" name="X-Requested-With" value="XMLHttpRequest" /> | |
<input type="text" name="Name" value="" /> | |
<input type="text" name="Email" value="" /> | |
<input type="button" class="submitButton" value="Get Your Guide Now" /> | |
</form> | |
<script type="text/javascript"> | |
$(function () { | |
jQuery('#courseGuideForm .submitButton').click(function () { | |
// Do validation on the name | |
// then on the email | |
// if all good, ajax post | |
console.log("submit form"); | |
$.post('/Home/FreeCourseGuide', // URL | |
{ Name: "Vijay Santhanam", Email: "[email protected]", "X-Requested-With": "XMLHttpRequest" }, // DATA | |
function (data, textStatus) { | |
console.log(textStatus); | |
console.log(data); | |
}); | |
/* | |
$('#courseGuideForm').ajaxForm(function (result) { | |
console.log(result); | |
alert('form successfully submitted'); | |
return false; | |
}); | |
*/ | |
//return false; | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment