May I know what is the difference for the script below (With $when vs without $when for ajaxRequest )
$.when(ajaxRequest("GET", "Api/Filter/Country", null, true)).done(function (data) {
return data;
});
And below
ajaxRequest("GET", "Api/Filter/Country", null, true).done(function (data) {
return data;
});
Main Function
ajaxRequest: function (type, url, data) {
var options = {
dataType: "json",
contentType: "application/json",
cache: false,
type: type,
data: data ? ko.toJSON(data) : null
};
var antiForgeryToken = $("[name='__RequestVerificationToken']")[0].value;
if (antiForgeryToken) {
options.headers = {
'RequestVerificationToken': antiForgeryToken
}
}
return $.ajax(url, options);
}