I went through the suggested related topics before asking this question but none of them could solve my problem. So in advance, sorry for a possible dubplicate..
In my ASP.NET MVC3 application I have following function that is attached to a button:
save: function () {
$.ajax({
url: "@Url.Action("Save")",
type: "post",
data: ko.toJSON(this),
contentType: "application/json",
succes: function (result) { alert(result.message) },
});
}
In my Controller I have a JsonResult-method like this:
public JsonResult Save(Person person)
{
//process person-parameter and send message back
var message = "Dummy result-message";
return Json(new { message });
}
And these are the JavaScript – files I have referenced:
<script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/modernizr-1.7.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.tmpl.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/knockout-1.2.1.js")" type="text/javascript"></script>
I debugged the application using breakpoints and the button – event is fired like it should and the method in the Controller is called. The processing of the Person-parameter is done and I call the return – statment. But the problem is: I don’t get an alert…
For a couple of hours now I’ve been looking on the internet on how to solve this but I can’t seem to find the solution. I hope any of you guys can get me back on the right track. Thanks in advance!
success setting is misspelled 🙂