Use jQuery ajax:
function AddToCart(id)
{
$.ajax({
url: 'urlToController',
data: { id: id }
}).done(function() {
alert('Added');
});
}
More Related Contents:
- ASP.NET MVC 3 Razor: Include JavaScript file in the head tag
- ASP.NET MVC implement custom validator use IClientValidatable
- Using Razor within JavaScript
- Razor MVC Populating Javascript array with Model Array
- asp.net-mvc: razor ‘@’ symbol in js file
- Populate a Razor Section From a Partial
- Razor Syntax and Javascript
- Is it OK to put JavaScript in Partial Views
- Does Angular routing template url support *.cshtml files in ASP.Net MVC 5 Project?
- jQuery: How to traverse / Iterate over a list of object
- Razor/JavaScript and trailing semicolon
- Javascript, Razor and Escape characters. Like apostrophe
- Share constants between C# and Javascript in MVC Razor
- Auto refresh in ASP.NET MVC
- ASP.NET MVC Partial view ajax post?
- Conditional Compilation is turned off in Razor?
- Using Razor, how do I render a Boolean to a JavaScript variable?
- Passing data to a bootstrap modal
- How to pass json POST data to Web API method as an object?
- Relative Paths in Javascript in an external file
- Razor: Declarative HTML helpers
- ASP.NET MVC 3 Razor – Adding class to EditorFor
- Is it possible to create a generic @helper method with Razor?
- Passing dynamic javascript values using Url.action()
- Difference between $.post and $.ajax?
- Does Razor syntax provide a compelling advantage in UI markup?
- using javascript variable in MVC3 Razor view engine
- How to retain spaces in DropDownList – ASP.net MVC Razor views
- How to get JSON object from Razor Model object in javascript
- How to post ASP.NET MVC Ajax form using JavaScript rather than submit button