Last active
January 5, 2018 20:04
-
-
Save bcnzer/b6ff241080d34db9eff03a601d7a1876 to your computer and use it in GitHub Desktop.
Portion of the cshtml containing the JQuery
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
@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