无法post到控制器里的方法

MicroBlogHelper里:
private static void DeleteArticle(int articleId)
{
string sql = String.Format("DELETE FROM blog_article WHERE Id={0}", articleId);
AdoHelper.ExecuteNoQuery(sql);
}
public static Article ADeleteArticle(int articleId)
{
var article = SingleArticleDTO(articleId);
DeleteArticle(article.Id);
return article;
}
控制器里: public ActionResult DeleteBlog(int articleId)
{
var article = MicroBlogHelper.ADeleteArticle(articleId);
if (article.Id == 0)
{
return Json(new { Result = false, Message = "微博删除失败" }, JsonRequestBehavior.AllowGet);
}
return Json(new { Result = true, Message = "微博删除成功" }, JsonRequestBehavior.AllowGet);

}

JS:var store = {
//获取blog列表
listblog: function (success) {
$.ajax({
url: "/microblog/bloglist",
type: "get",
dateType: "json",
cache: false,
success: success
});
},
//删除博客
deleteBlog: function (data, success) {
$.ajax({
url: "/microblog/deleteblog",
type: "post",
dateType: "json",
data: data,
success: success
});
},
};
var viewModel = {
model: {
blog: {
BlogId: 0,
Content: "",
RemainCount: 140
},
blogList: [],
},
init: function () {
//将Model进行KO映射
this.model = ko.mapping.fromJS(this.model);
ko.applyBindings(this);
//显示数据
this.listBlog();
},
//获取列表的数据并赋值
listBlog: function () {
var self = this;
store.listblog(function (data) {
self.model.blogList(data);
});
},
//删除博客
Blogdelete: function () {
var data = ko.mapping.toJS(this.model.blog);
var self = this;
store.deleteBlog(data, function (result) {
if (result.Result) {
alert(result.Message);
} else {
alert(result.Message);
}
$("#delete").modal("hide");
self.listBlog();
});
},
//显示删除信息
showDeleteblog: function (blogId) {

        this.model.blog.BlogId = blogId;
        $("#delete").modal("show");
    },
            };

$(function () {
    viewModel.init();
})

})(jQuery);

html代码:
删除  

确定删除?
删除 关闭

4个回答

同求解,有人回答吗?

同求解,我等到花儿也谢了?

//删除博客
deleteBlog: function (data, success) {
$.ajax({
//这里添加debugger
url: "/microblog/deleteblog",
type: "post",
dateType: "json",
data: data,
//debugger
success: success
});
}

1>.确保Ajax方法是否执行?
2>.执行了返回的data,可以打印出来看看

[HttpPost]
public ActionResult DeleteBlog(int articleId)

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐