I have the JQuery code:
$(document).ready(function() {
$('.LikeArea').click(function() {
var num = parseInt(this.html());
num++;
elem.html(num);
});
});
Now I want to pass the jQuery variable num to Razor so I can update the database with the new value.
Razor is a view engine. Not really sure what you mean when you say that you want to pass a jQuery variable to Razor because Razor runs on the server before any javascript. You could use AJAX though to send a request to a server side template:
which would send an AJAX request to the
/foo.cshtml
template in which you can fetch the variable like this: