I am working on a tool that allows the user to type some IDs, and check if these IDs exist in the database.
The code was written to work with SOLR database, so if the ID didn't exist there was no problem. Now though I am talking to CouchDB, so if the ID doesn't exist, the tool will give no result and produce a 404 error: 404 (Object Not Found).
Here is my code:
// ...
function caller() {
if (validIDs.length === 0) {
promise.resolve();
return;
}
var ID = validIDs.pop();
var url = preURL + ID;
var wrappedResult = {
"ID": ID,
"data": undefined
};
$.getJSON(url).done(function(data) {
wrappedResult["data"] = data;
caller();
});
wrappedResults.push(wrappedResult);
}
caller();
return [promise, wrappedResults];
}
I tried to use something like:
$.getJSON({
url: url,
dataType: "json",
success: function(data) {
wrappedResult["data"] = data;
myForEach();
alert('success');
},
error: function(data) {
alert('error');
},
complete: function(xhr, data) {
if (xhr.status !== 0)
alert('success');
else
alert('fail');
}
});
But it did not work. the html doesn't display the table, and in the console: 404 (Object Not Found)
I looked at the solution suggested in other similar question but they did not solve my problem.
Please is there a way my code can continue showing the results of the accepted IDs and point out the invalid ones?