Created
February 27, 2018 21:46
-
-
Save Cj1m/2812c0416e0a7a58439d9f02702648f5 to your computer and use it in GitHub Desktop.
ajax post request
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
$('#swimmer-submit').on('click', function(e) { | |
e.preventDefault(); | |
var values = { | |
swimmer : { | |
swimmer_forename: $('input[name="swimmer_forename"]').val(), | |
swimmer_surname: $('input[name="swimmer_surname"]').val(), | |
swimmer_dob: $('input[name="swimmer_dob"]').val(), | |
swimmer_gender: $('select[name="swimmer_gender"]').val(), | |
} | |
}; | |
$.ajax({ | |
url: "/addrecords", | |
type: "POST", | |
contentType: "application/json", | |
data: JSON.stringify(values), | |
success: function(response) { | |
if (response) { | |
console.log('Alerting success and clearing form'); | |
alert("Success!"); | |
} | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment