Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/319.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ajax.beginform-OnFailure不返回部分视图_C#_Asp.net Mvc_Model View Controller_Asp.net Ajax_Ajax.beginform - Fatal编程技术网

C# ajax.beginform-OnFailure不返回部分视图

C# ajax.beginform-OnFailure不返回部分视图,c#,asp.net-mvc,model-view-controller,asp.net-ajax,ajax.beginform,C#,Asp.net Mvc,Model View Controller,Asp.net Ajax,Ajax.beginform,你好 我使用的是ajax.beginform,我想返回带有 里面有错误。我能把状态码改成什么坏东西来开火吗 OnFailure方法不返回部分视图。该观点称: js: $(文档).ready(函数() { }); 函数firstsuccess(数据){ 控制台日志(数据); $('partialsocio').html(数据); log(“这是ajaxSuccess”); } 函数SocialDetailsFail(bdata){ log('这是ajaxfail'); 控制台日志(数据); $(

你好

我使用的是ajax.beginform,我想返回带有 里面有错误。我能把状态码改成什么坏东西来开火吗 OnFailure方法不返回部分视图。该观点称:

js:


$(文档).ready(函数()
{
});
函数firstsuccess(数据){
控制台日志(数据);
$('partialsocio').html(数据);
log(“这是ajaxSuccess”);
}
函数SocialDetailsFail(bdata){
log('这是ajaxfail');
控制台日志(数据);
$('partialsocio').html(数据);
}
请帮我解决这个问题


如果您的请求失败,那么您将从服务器获得回调,包括
socialdetailsfail
witinjava脚本中的问题定义,如果您的请求失败,您可以使用逻辑显示从服务器
bdata
对象接收到的错误消息给用户如果您的请求失败,那么您将从服务器获得回调,包括
SocialDetailsFail
witin java脚本中的问题定义,您可以将逻辑放在哪里,以显示从服务器
bdata
对象接收到的错误消息给用户

您的页面中是否有
jquery.unobtrusive ajax.js
的引用?是的,我添加了此引用您的引用顺序是什么?你能告诉我们你是如何引用它们的吗?我有个问题,文本在返回的代码中。你的页面中有
jquery.unobtrusive ajax.js
的引用吗?是的,我添加了这个引用。你的引用顺序是什么?你能告诉我们你是如何引用它们的吗?我有一个问题,文本在返回的代码中,但是bdata没有返回我想在视图中重新加载的部分视图。他有错误代码,内部没有部分视图,但bdata没有返回我要在视图中重新加载的部分视图。他有内部没有局部视图的错误代码
<fieldset>
@using (Ajax.BeginForm("SaveSocioDetails", "Student", new AjaxOptions { HttpMethod = "POST", OnSuccess = "firstsuccess",OnFailure = "sociodetailsfail", UpdateTargetId="partialsocio" ,LoadingElementId = "div_loading" }, new { @enctype = "multipart/form-data" }))
{
    @Html.AntiForgeryToken()
<div id="partialsocio">
    @Html.Action("PartialSocioDetails", "Student", new { SpId = ViewBag.SpId })
</div>
        <div id="div_loading" style="display:none;">
        <img src="@Url.Content("~/Content/Pic/Spinner.gif")" alt="" />
    </div>
    <button class="btn btn-primary" type="submit" value="Submit">שלח</button>
}
<input type="button" name="next" class="next action-button" value="Next" />
 [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult SaveSocioDetails(SpSocio socio) // ajax for 1 step in socio
        {
            socio.StudentId = sStudentId; // bind student id to socio model
            bool sociook = SocioDetValid(socio);
            // add validation
            if (ModelState.IsValid && sociook)
            {
                SaveSocioModel(socio);
                Response.StatusCode = 200;
            }
            else
               Response.StatusCode = 300; // return error to client the model is not valid
            return PartialView("~/Views/Student/Socio/SocioDetails.cshtml", socio); // return the partial view of the forn with validation messages
        }
<script>
   $(document).ready(function ()
    {
    });

    function firstsuccess(data) {
        console.log(data);
        $('#partialsocio').html(data);
        console.log('this is ajaxSuccess');
    }

    function sociodetailsfail(bdata) {
         console.log('this is ajaxfail');
        console.log(data);
        $('#partialsocio').html(data);
    }
</script>