How can i handle Ajax deferred error
function CallingApi() {
return $.ajax({
url: 'http://localhost:10948/Api/Home/GetEmployee123',
contentType: 'application/x-www-form-urlencoded',
type:'GET',
})
}
function Errorfunction(xhr) {
//alert(xhr.status);
}
Here I'm calling Ajax PromiseApi
is working fine but if there is any error, how can I alert there is an Error
var PromiseApi = CallingApi();
var ErrorPromise = Errorfunction();
PromiseApi.done(function (data) {
$.each(data, function (i, value) {
console.log(value.EmpName);
})
})