Translate

Wednesday, 18 November 2015

Ajax and getJSon functions to call a method in MVC



Ajax and getJSON functions to call a method in mvc


Ajax function:

<script>
    $(document).ready(function () {
            $.ajax({
                url: '@Url.Action("test","JqGrid")', type: "POST", datatype: "JSON", data: { id: $("#txtMobile").val(), Name: $("#txtName").val() }, success: function (data) {
                    if (data != null) {
                        alert("success");
                        //$.each(data, function (sample, i) {
                        //});
                    }
                }
            });
           
        });
</script>


getJSON function

<script>
    $(document).ready(function () {
           
            $.getJSON('@Url.Action("test","JqGrid")', { id: $("#txtMobile").val(), Name: $("#txtName").val() }, function (data) {
                if (data != null) {
                    alert("success");
                }
            });
        });

</script>

No comments:

Post a Comment