locked
Modal not showing RRS feed

  • Question

  • User1979860870 posted

    Hi

      In Layout i have below code

     <div id="errorModal" title="Message" style="display:none;">
        </div>
    
    In Js file
    *********
    function Add() {
        var objLocation = {
            Id: $('#Id').val().toUpperCase(),
            Description: $('#Description').val().toUpperCase()
        };
        $.ajax({
            url: "/Location/Add",
            data: JSON.stringify(objLocation),
            type: "POST",
            contentType: "application/json;charset=utf-8",
            dataType: "json",
            success: function (result) {
                $("#errorModal").html("Record Successfully Saved ?");
                $("#errorModal").modal('show');
                loadData();
                $('#myModal').modal('hide');
            },
            error: function (errormessage) {
                alert(errormessage.responseText);
            }
        });
    }

    Thanks

    Sunday, May 16, 2021 7:17 AM

All replies

  • User475983607 posted

    You did not share enough code to reproduce this issue or explain what modal library you are using.  The code you have shown does not make a lot of sense.  How is the Id and message populated?  These two items add a new location???

    The first step is opening the browser's  dev tools to see if there are any errors in the Console window.  If there are no error then most likely the code is not running.  Set a break point in the Add() function and step your your code.

    In a recent post you asked how to debug JavaScript in Chrome.; https://forums.asp.net/p/2176232/6338535.aspx?Code+Debug.    Please make an effort to debug your code.

    Sunday, May 16, 2021 10:13 AM
  • User287926715 posted

    Hi jagjit saini,

    Did you open the F12 debugging tool if there was an error, and if so, where is it located?

    If you can, can you provide some complete code?

    Best Regards,

    ChaoDeng

    Monday, May 17, 2021 9:08 AM