Going bonkers here and have been using jquery's ajax for years and still can't figure out what is wrong even though there is nothing wrong with the syntax nor the service that it is calling, but the success, error and complete events simply won't fire. I put an alert & a log to console and nothing happens.
$.ajax({
url: 'DDService.asmx/LoadCountries',
dataType: 'json',
method: 'post',
data: {},
success: function (data) {
alert('success');
console.log('success');
},
error: function (err) {
alert('error');
console.log('Error (RetrieveCountriesDD): ' + JSON.stringify(err, null, 2));
},
complete: function () {
alert('complete');
console.log('complete');
}
});
I put a code break in the service and it is being called and returning json (like I said, I've done this many times before and this is baffling me) which I've specified, I changed the dataType to text, html and even removed it altogether, still no events fire nor are there any errors anywhere. Using jQuery 3.3.1 - though all other ajax calls all over the place with identical syntax is working (is there something I'm missing here?). Sample of what is returned by the webservice:
[{"T":"United States","V":"1"},{"T":"Canada","V":"2"},{"T":"Afghanistan ","V":"86"},{"T":"Albania ","V":"89"},{"T":"Algeria ","V":"117"},{"T":"American Samoa ","V":"92"},{"T":"Andorra ","V":"90"},{"T":"Angola ","V":"87"},{"T":"Anguilla ","V":"88"},
Anyone know what would cause the ajax events to not fire? NOTE: I left out the data parsing portion (to fill a simple dropdown) for brevity since that is not where the problem is - an alert box should show up or something in the console, but nothing at all happens after the service is called.