Reputation: 27
I have javascript function for update partial view. Now i need to update partial view that take one value and i cant do it :(
here is my function that works:
function clearData() {
var urlclear = '@Url.Action("Clear", "Cart")';
$.ajax({
cache: false,
type: 'POST',
url: urlclear,
success: function (data) {
$('#AjaxUpdate').html(data);
}
});
}
and if i put:
function clearData(id) {
var urlclear = '@Url.Action("Clear", "Cart", new {ID = id})';
$.ajax({
cache: false,
type: 'POST',
url: urlclear,
success: function (data) {
$('#AjaxUpdate').html(data);
}
});
}
it tells me that id is undefined.
Can someone please tell me what im doing wrong.
thx in advance.
Upvotes: 1
Views: 727
Reputation: 16144
var urlclear = '@Url.Action("Clear", "Cart")' + "?ID=" + id;
OR
var urlclear = '@Url.Action("Clear", "Cart")' + "/" + id;
Upvotes: 1
Reputation: 218722
Replace
var urlclear = '@Url.Action("Clear", "Cart", new {ID = id})';
with
var urlclear = "@Url.Action("Clear", "Cart")/"+id;
Upvotes: 2