Call another method onSuccess event of an Ajax call
I have an AJAX call on MVC3 it looks like this
save: function () {
$.ajax({
url: "@Url.Action("Save")",
type:"post",
data: ko.toJS开发者_如何学GoON(this),
contentType:"application/json",
success: function(result){alert(result.message)}
});
}
The trouble is the line
success: function(result){alert(result.message)}
I want to pass all the messing things in a HtmlHelper, however, the success line prevents me from doing so, is there a way I can specify a function for that line
success: doSomeStuff(result)
and
function doSomeStuff(result){alert(result.message)}
Thanks in advance
Simply pass the function name to the success
: method and it will pass the data onwards, as such:
save: function () {
$.ajax({
url: "@Url.Action("Save")",
type:"post",
data: ko.toJSON(this),
contentType:"application/json",
success: doSomeStuff
});
}
精彩评论