Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The HTTP verb POST used to access path '/Documents/TestNote/Documents/AddNote' is not allowed

I am having two user control on a aspx page and one of the user control has a text area for notes. and i am trying to use JSON so that when they click the addnote button it does not reload the page.

Below is my java script , but it says that it is giving this error

The HTTP verb POST used to access path '/Documents/TestNote/Documents/AddNote' is not allowed.

<script type="text/javascript">
    $(document).ready(function() {

        $("#btnAddNote").click(function() {
            alert("knock knock");
            var gnote = getNotes();
            //var notes = $("#txtNote").val();
            if (gnote == null) {
                alert("Note is null");
                return;

            }

            $.post("Documents/AddNote", gnote, function(data) {
                var msg = data.Msg;
                $("#resultMsg").html(msg);
            });
        });
    });

    function getNotes() {
        alert("I am in getNotes function");
        var notes = $("#txtNote").val();
        if (notes == "")
            alert("notes is empty");
        return (notes == "") ? null : { Note: notes };
    }
</script>

My controller

[HttpPost]
    public ActionResult AddNote(AdNote note)
    {
        string msg = string.Format("Note {0} added", note.Note);
        return Json(new AdNote { Note = msg });


    }
like image 479
user331772 Avatar asked Feb 03 '26 09:02

user331772


1 Answers

in the controller use

return Json(new AdNote { Note = msg },sonRequestBehavior.AllowGet);
like image 54
mobarmg Avatar answered Feb 05 '26 08:02

mobarmg



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!