I have a problem which is similar to this stackoverflow
I am sending a list of selected objects to an “Update” method. That works fine, the problem is on the success callback. It does not happen for some reason. The page just sort of blinks once. In firebug’s net tab I can see call to the url. The controller returns bool so in the Response I just have true. But obviously what I want to do is update the page based on that bool. This is MVC2 project-not sure if this has to do with it.
$.ajax({
url: "/Update/UpdateAll",
dataType: 'json',
type: "POST",
data: { selected: selected, statusID: statusID },
success: function (result) {
if (result) {
alert('all successful');
$('#resultsFromUpdate').html("Success");
}
else {
alert('no deal');
$('#resultsFromUpdate').html("Fail");
}
}
});
and UpdateAll controller method:
public bool UpdateAll(string selected, string statusID)
{
...
> update some things
> return true if fine
> return fasle if not
...
}
This is exactly the point of using AJAX, not requiring a page post…So what am I doing wrong ?
Should really have a JsonResult as your return type, as you specified “json” as what the $.ajax method should expect. Also, the $.post method is usually easier to use.