I have this kind of javascript:
$.ajax({
url: "//myapi.com/json",
dataType: "jsonp"
}).done(function (data) {
selectText('Id', data.country);
}).fail(function (jqXHR, textStatus, errorThrown) {
var defaultOption = 'US'
selectDropdownByText('Id', defaultOption);
console.log(errorThrown);
});
But the thing is that on https request my ajax is not working because service I am calling is not accessible via https and I am getting error :ERR_CONNECTION_REFUSED
- so that is fine, I just want to handle that. I have .fail
in ajax call, but it is not handling :ERR_CONNECTION_REFUSED
Could you give advice on how to handle :ERR_CONNECTION_REFUSED
in that case?
I also was trying to wrap my ajax call to try-catch
block, but it wasn't working either.