jquery

jQuery AJAX Methods

A
Desh-Duniya Team Author
| Published May 29, 2019
function GetAJAX() {  
            $.ajax({
                url: "@Url.Action("ActionMethod", "Controller")",
                type: "POST",
                dataType: "JSON",
                data: { id: id},
                success: function (courserGroups) {
                    $.each(da, function (i, cg) {
                        
                    });
                }
                , complete: function () {
                }, error: function (jqXHR, status, error) {
                    if (jqXHR.status == 403) {
                        alert("Sorry, your session has expired. Please login again to continue");
                    } else if (jqXHR.status === 0) {
                        alert('Not connected Verify Network.');
                    } else if (jqXHR.status == 404) {
                        alert('Requested page not found. [404]');
                    } else if (jqXHR.status == 500) {
                        alert('Internal Server Error [500].');
                    } else if (exception === 'parsererror') {
                        alert('Requested JSON parse failed.');
                    } else if (exception === 'timeout') {
                        alert('Time out error.');
                    } else if (exception === 'abort') {
                        alert('Ajax request aborted.');
                    } else {
                        alert("An error occurred: " + status + "nError: " + error);
                    }
                }
            });
        }

Discussion (0)

Please sign in to participate in the discussion.
No comments yet. Be the first to join the conversation!