0

in javascript when I wrap my functions (below) in either $(Document).ready(Function(){ ... }) or $function(){ ... } I receive errors that the my function AddContact or EditContact is not found. I am using MVC and this was what I thought would a remedy my issue with javascript being not found after HttpPost, so if someone could explain how to wrap these inside ot $.ready(function() maybe I could resolve both issues.

<script>
       var AddContact = function (id) {

            var url = "../Dataset/AddContact/" + id
            $("#myModalBody").load(url, function () {
                $("#myModal").modal("show");
            })


        };

        var EditContact = function (id) {

            var url = "../Dataset/EditContact/" + id
            $("#myModalBody").load(url, function () {
                $("#myModal").modal("show");
            })


        };
</script>
Paul T. Rykiel
  • 1,177
  • 6
  • 26
  • 48
  • Because the functions will not be in global scope. They will be scoped to the document.ready function. – epascarello Mar 13 '21 at 19:57
  • [Duplicate](https://google.com/search?q=site%3Astackoverflow.com+jquery+function+inside+document.ready+not+found) of [jQuery - function inside $(document).ready function](https://stackoverflow.com/q/6780890/4642212) or [Javascript function inside document.ready](https://stackoverflow.com/q/18504253/4642212). – Sebastian Simon Mar 13 '21 at 20:00

0 Answers0