locked
POST 500 (Internal Server Error) RRS feed

  • Question

  • User-1725652363 posted

    Hi I have some issues to solve this:  I have a popup confirmation with two buttons: "Confirm" and "Cancel"   when I click on Confirm I want to hide the modal and send  "param" to the server, execute "ModifierStatut"s function and refresh the page to see the modification

    This is the code: 

    <script>
    var modalConfirm = function (param) {
            console.log(param);
            $("#statut").modal('show');
            $("#confirmer").on("click", function () {
                $("#statut").modal('hide');
                $.ajax({
                    type: "POST",
                    data: param,
                    url: "/Norme/ModifierStatut",
                    success: function () {
                        window.location.href = "/Norme/Norme";
                    }
                });
                console.log("click");
            });
        };
    </script>

    When I click on Confirm button I get this error:

    POST http://localhost:51923/Norme/ModifierStatut 500 (Internal Server Error)

    what's wrong on my side?

    Thanks in advance

    Monday, May 21, 2018 1:56 PM

Answers

  • User-369506445 posted

    hi

    please try below code :

    in View

     <script src="~/Scripts/jquery-3.3.1.min.js"></script>
    <script>
        var modalConfirm = function (param) {
            console.log(param);
            $("#statut").modal('show');
            $("#confirmer").on("click", function () {
                $("#statut").modal('hide');
                $.ajax({
                    type: "POST",
                    data: { par: "test" },
                    url: "/Norme/ModifierStatut",
                    success: function () {
                        window.location.href = "/Norme/Norme";
                    }
                });
                console.log("click");
            });
        };
    </script>

    in Controller

    [HttpPost]
            public ActionResult ModifierStatut(string par)
            {
                //some tasks
                return View("Norme");
            }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 21, 2018 2:54 PM

All replies

  • User753101303 posted

    Hi,

    The http 500 status means that you have a server side exception which by default should be written to the Windpws Application log.

    Monday, May 21, 2018 1:58 PM
  • User-1725652363 posted

    How can I display this window?

    Monday, May 21, 2018 2:00 PM
  • User475983607 posted

    A 500 error is a server side error.  A 500 can be due to the unexpected parameter format.  It can also be the controller code is not handling errors.  There's really no way to provide assistance without the source code and a sample that reproduces the issue.

    Have you tried setting a breakpoint in the action to determine of the action is invoking?

    Monday, May 21, 2018 2:03 PM
  • User-1725652363 posted

    A 500 error is a server side error.  A 500 can be due to the unexpected parameter format.  It can also be the controller code is not handling errors.  There's really no way to provide assistance without the source code and a sample that reproduces the issue.

    Have you tried setting a breakpoint in the action to determine of the action is invoking?

    This is the Action:

     public ActionResult ModifierStatut(string par)
            {
               //some tasks
                return View("Norme");
            }


    I get null in par

    Monday, May 21, 2018 2:12 PM
  • User753101303 posted

    Try for example https://www.sevenforums.com/tutorials/226084-event-viewer-open-use-windows-7-a.html for how to access the Application log.

    Monday, May 21, 2018 2:17 PM
  • User-1725652363 posted

    The problem in the param because I didn't get it in the Action, you know how can I do?

    Monday, May 21, 2018 2:23 PM
  • User-369506445 posted

    hi

    please try below code :

    in View

     <script src="~/Scripts/jquery-3.3.1.min.js"></script>
    <script>
        var modalConfirm = function (param) {
            console.log(param);
            $("#statut").modal('show');
            $("#confirmer").on("click", function () {
                $("#statut").modal('hide');
                $.ajax({
                    type: "POST",
                    data: { par: "test" },
                    url: "/Norme/ModifierStatut",
                    success: function () {
                        window.location.href = "/Norme/Norme";
                    }
                });
                console.log("click");
            });
        };
    </script>

    in Controller

    [HttpPost]
            public ActionResult ModifierStatut(string par)
            {
                //some tasks
                return View("Norme");
            }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, May 21, 2018 2:54 PM
  • User-1725652363 posted

    hi

    please try below code :

    in View

     <script src="~/Scripts/jquery-3.3.1.min.js"></script>
    <script>
        var modalConfirm = function (param) {
            console.log(param);
            $("#statut").modal('show');
            $("#confirmer").on("click", function () {
                $("#statut").modal('hide');
                $.ajax({
                    type: "POST",
                    data: { par: "test" },
                    url: "/Norme/ModifierStatut",
                    success: function () {
                        window.location.href = "/Norme/Norme";
                    }
                });
                console.log("click");
            });
        };
    </script>

    in Controller

    [HttpPost]
            public ActionResult ModifierStatut(string par)
            {
                //some tasks
                return View("Norme");
            }

    Yes it works!

    I miss data :data: { par: "test" } :p 

    Thank you :) :) 

    Monday, May 21, 2018 3:02 PM