Skip to content

Instantly share code, notes, and snippets.

@bcnzer
Last active January 5, 2018 20:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bcnzer/b6ff241080d34db9eff03a601d7a1876 to your computer and use it in GitHub Desktop.
Save bcnzer/b6ff241080d34db9eff03a601d7a1876 to your computer and use it in GitHub Desktop.
Portion of the cshtml containing the JQuery
@section Scripts {
<script type="text/javascript">
function determineStorageLocation() {
var token = $('input[name="__RequestVerificationToken"]', $('#bookForm')).val();
var myData = { isHardcover: $("#IsHardcover").val() };
var dataWithAntiforgeryToken = $.extend(myData, { '__RequestVerificationToken': token });
$.ajax({
url: "/BookDetails/StorageLocations",
type: "POST",
data: dataWithAntiforgeryToken,
success: function (data) {
$("#StorageLocations").empty();
data.forEach(function (element) {
$("#StorageLocations").append("<option>" + element.LocationName + "</option>");
});
},
error: function () {
$("#StorageLocations").empty();
}
});
}
$("#IsHardcover").on('change', determineStorageLocation);
</script>
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment