I want to send data from view to another controller using JQuery
var title;
var price;
var container;
$('a.btn').click(function () {
container = $(this).closest('.item');
title = container.find('.item-dtls > h4 > a').text();
price = container.find('.price').text();
});
$('a.btn').click(function () {
$.ajax({
url: '@(Url.Action("Item", "Home"))',
type:'POST',
datatype:text,
data:{title,price},
success: function (data) {
alert('success');
},
error: function (data) {
alert('error');
}
});
});
This is my controller
[HttpPost]
public ActionResult Item(string title,string price) {
Response.Write(title);
}
@Url.statement.