Skip to content

Instantly share code, notes, and snippets.

@sdglhm
Created June 25, 2015 16:01
Show Gist options
  • Save sdglhm/31383092286168f5b6bc to your computer and use it in GitHub Desktop.
Save sdglhm/31383092286168f5b6bc to your computer and use it in GitHub Desktop.
<script type="text/javascript">
$(function () {
$('form').on('submit', function (e) {
e.preventDefault();
//added comment to show usage
$.ajax({
type: 'post',
url: 'src/secure_function.php',
data: $('form').serialize(),
success: function (data) {
$('#result').html('');
$('#result').html(data);
var str = data.match('<div class="alert alert-success alert-dismissable fadeIn"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button><strong>Email sent successfully! We will contact you as soon as possible.</div>')
if (str) {document.getElementById("contact_frm").reset();};
}
});
});
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment