开发者

Does a form gets closed after form.submit()?

开发者 https://www.devze.com 2022-12-31 16:09 出处:网络
I have the following code: $.ajax({ type: \"POST\", url: \'<%=Url.Action(\"test\",\"pepole\") %>\',

I have the following code:

$.ajax({
        type: "POST",
        url: '<%=Url.Action("test","pepole") %>',
        data: $("#PeopleForm").submit(),
        contentType: "application/json; charset=utf-8",
        dataType: "html",
        sucess: function() {
        },
        error: function(request, status, error) {
        $("#NotSelectedList").html("Error: " & request.responseText);
        }
    });

The PeopleForm is displayed in a dialog. After the submit, the dialog gets closed. Is that normal? I don`t开发者_如何学运维 want the dialog to get closed after the submit. How can I do that?

The controller is as below:

public ActionResult test(Model model)
    {
        model.SaveNotification();
        return RedirectToAction("Index");
    }

public ActionResult test(Model model)
        {
            model.SaveNotification();
            return  Json(new { Result = true });
        }


Submit submits a form, browser to leave the current page and go to wherever the action of the form says to go.

The dialog doesn't "close", a new page loads.

You probably want serialize, not submit.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号