调用 Ajax 调用的另一个方法 onSuccess 事件
我在 MVC3 上有一个 AJAX 调用,看起来像这样
save: function () {
$.ajax({
url: "@Url.Action("Save")",
type:"post",
data: ko.toJSON(this),
contentType:"application/json",
success: function(result){alert(result.message)}
});
}
问题是
success: function(result){alert(result.message)}
我想在 HtmlHelper 中传递所有混乱的东西,但是,成功行阻止我这样做,有没有办法可以为此指定一个函数线
success: doSomeStuff(result)
并
function doSomeStuff(result){alert(result.message)}
提前致谢
I have an AJAX call on MVC3 it looks like this
save: function () {
$.ajax({
url: "@Url.Action("Save")",
type:"post",
data: ko.toJSON(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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需将函数名称传递给
success
: 方法,它将继续传递数据,如下所示:Simply pass the function name to the
success
: method and it will pass the data onwards, as such: