jquery attach ajax beforeSend on all requests code example

Example 1: jquery wait for all ajax requests to complete

//jQuery waiting for all ajax calls to complete b4 running
$.when(ajaxCall1(), ajaxCall2()).done(function(ajax1Results,ajax2Results){
    //this code is executed when all ajax calls are done
});

function ajaxCall1() {
    return  $.ajax({
        url: "some_url.php",
        success: function(result){
            console.log(result); 
        }
    });
}   

function ajaxCall2() {
    return  $.ajax({
        url: "some_url.php",
        success: function(result){
            console.log(result); 
        }
    });
}

Example 2: how to execute something after ajax call

BY LOVE,
 1- "beforeSend" event used to execute something before ajax call
 2- "complete"   event used to execute something after the ajax called successfull.
 
$.ajax({
                url: ' @Url.Action("AttendanceUpdateLate", "Attendance")',
                data: { Emp: $("#txtEmpid").val(), Status: $("#ddlAttendance").val(), day: $("#ddlday").val(), Month: $("#Month").val() },
                datatype: "json",
                type: "POST",
                contenttype: 'application/json; charset=utf-8',
                async: true,
                success: function (data) {
                    alert(data);
                },
                beforeSend: function () {
                    alert("Alert showing before AJAX call");

                },
                complete: function () {
                  alert("Alert showing after AJAX call successfully");
                    $("#txtEmpid").val('');
                    $("#ddlday").val('');
                    $("#ddlAttendance").val('');
                },
                error: function (xhr) {
                    alert('error occured');
                }
            });