updates to include error handling in external concept services

This commit is contained in:
hjkhjk54 2011-12-02 22:03:52 +00:00
parent 2fb20f1efe
commit f9d402bff6
11 changed files with 184 additions and 32 deletions

View file

@ -142,16 +142,17 @@ var addConceptForm = {
}
var vocabSourceValue = checkedVocabSource.val();
var dataServiceUrl = addConceptForm.dataServiceUrl + "?searchTerm=" + encodeURIComponent(searchValue) + "&source=" + encodeURIComponent(vocabSourceValue);
$.getJSON(dataServiceUrl, function(results) {
//This should return an object including the concept list or any errors if there are any
$.getJSON(dataServiceUrl, function(results) {
var htmlAdd = "";
if ( results== null || results.array == null || results.array.length == 0 ) {
htmlAdd = "<p>No search results found.</p>";
} else {
var vocabUnavailable = "<p>The vocabulary service is unavailable. Please try again later.</p>";
if ( results== null || results.semanticServicesError != null || results.conceptList == null) {
htmlAdd = vocabUnavailable;
}
else {
//array is an array of objects representing concept information
//loop through and find all the best matches
var bestMatchResults = addConceptForm.parseResults(results.array);
var bestMatchResults = addConceptForm.parseResults(results.conceptList);
var numberMatches = bestMatchResults.length;
var i;
//For each result, display
@ -170,7 +171,7 @@ var addConceptForm = {
}
htmlAdd+= "</ul>";
} else {
htmlAdd+= "<p>No search results found.</p>";
htmlAdd+= "<p>No search results were found.</p>";
}
}

View file

@ -231,7 +231,8 @@ var customForm = {
dataType: 'json',
data: {
term: request.term,
type: customForm.acType
type: customForm.acType,
multipleTypes:(customForm.acMultipleTypes == undefined || customForm.acMultipleTypes == null)? null: customForm.acMultipleTypes
},
complete: function(xhr, status) {
// Not sure why, but we need an explicit json parse here.