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