views:

37

answers:

1

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 });
        }
+2  A: 

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.

David Dorward
With serialize, it doesn`t pass to the controller!
It might be breaking because you are claiming the data is application/json.
David Dorward
I have changed the code as in the edited part above, I`ts not returning the Json as expected. It`s displaying me the dialog box to save the json file. I already have Microsoft mvcajax and microsoftajax included.
Great, so you've changed it without implementing any of the suggestions I made above.
David Dorward