Ted
Ted

Reputation: 65

How to close a view from controller after running ActionResult

I am new at MVC and JS. I am trying to close a popup window after running Action in controller. However, I could not come up with a solution or found a working one. It seems to be an easy issue but it is still. I tried the solution at here and many others but it doesn't work.

ActionResult method in Controller. This collects all data on the popup window.

[ActionName("NewStudentSchedule")]
[HttpPost]
public ActionResult NewStudentSchedule_Submit(Student student)
{
    return View();
}

Window should close after clicking the Save button.

<input type="submit" class="btn btn-danger btn-lg" value="Save" /> 

Any help will be appreciated.

Upvotes: 1

Views: 294

Answers (1)

fatima_h66
fatima_h66

Reputation: 51

you can use from ajax call to call action method and then execute any task to you want.

same this code :

var finalParams = { Student : $('#Student').val() };
$.ajax({
                        url: "/ControllerName/NewStudentSchedule",
                        type: "POST",
                        dataType: 'json',
                        contentType: 'application/x-www-form-urlencoded; charset=UTF-8',
                        data: finalParams 
                    }).done(function (result) {
                        // do something with the result now
                        if (result.status === "success") {
                            $('#ListSection').load("/Resume/EducationHistoryList");
                            
                            $("#sectionMustbeClose").hide();


                        } else {
                            alert(result.message);
                        }
                    });

Upvotes: 1

Related Questions