模型弹出保存按钮使用MVC ajax.beginform probelm从控制器返回错误消息? [英] Model popup on save button using MVC ajax.beginform probelm for return error message from controller?

查看:77
本文介绍了模型弹出保存按钮使用MVC ajax.beginform probelm从控制器返回错误消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我面临的问题是从控制器返回的信息未显示在同一页面上被重定向到其他页面



我的代码查看:

Hi,

I am facing problem for returning message from controller not showing on same page is redirected to other page

My Code for view :

@using (Ajax.BeginForm("Components", "Controller", new AjaxOptions
                      {
                          HttpMethod = "POST",
                          OnFailure = "ShowError()",
                          UpdateTargetId = "ShowSuccess()"
                      }))





和脚本代码:



And Code For Script :

function ShowError() {


        $("#status").addClass("alert alert-error");      $("#status").removeClass();
        $("#status").html("<strong>Error!</strong> There was an error posting the contact form. Please try again later.");
    }

    function ShowSuccess() {

        $("#target").removeClass();
        $("#target").addClass("alert alert-success");
    }





控制器代码:



Code For Controller :

[HttpPost]
        public ActionResult Components(model objModel)
        {
            try
            {
                 // 
            }
        }

推荐答案

#status)。addClass( alert alert-error);
("#status").addClass("alert alert-error");


#status)。 removeClass();
("#status").removeClass();


#status)。 html( < strong>错误!< / strong>发布联系表单时出错。请重试后来的)。
}

函数ShowSuccess(){
("#status").html("<strong>Error!</strong> There was an error posting the contact form. Please try again later."); } function ShowSuccess() {


这篇关于模型弹出保存按钮使用MVC ajax.beginform probelm从控制器返回错误消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆