I'm going nuts here. I'm learning web and I'm trying to get some JQuery / AJAX functions to work:
If i were to remove the line:
var wtf = @Model.CurrentMatchDB.match_id;
then it works fine. but just that line alone breaks the function and I have no idea why. I really do want to pass the model members to the match_id and row_id under data.. but that isn't working neither.
I've been on this for a couple hours now, can anyone help me out? Thanks
<script>
$(document).ready(function () {
$('#button_setCurrMatch').click(function (e) {
e.preventDefault();
var wtf = @Model.CurrentMatchDB.match_id; //THIS LINE ERRORS
$.ajax('/CurrentMatch/ChangeMatchTest', {
type: 'POST',
data: {
match_id: "SUPPOSED TO BE A STRING FROM the MODEL HERE",
row_id: "SUPPOSED TO BE AN INT FROM THE MODEL HERE"
},
success: function () {
alert('SUCCESS');
},
error: function (request, errorType, errorMessage) {
alert("Error: " + errorType + " with message: " + errorMessage);
}
});
});
});
</script>