Changeset 38238
- Timestamp:
- 2023-09-27T21:02:34+13:00 (8 months ago)
- Location:
- main/trunk/greenstone3/web/interfaces/default/js
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/gsajaxapi.js
r32873 r38238 203 203 //alert(scriptURL + "?" + params); 204 204 //alert(xmlHttp.responseText); // if synchronous, process xmlHttp.responseText AFTER send() call 205 if(xmlHttp.status != 200 206 || xmlHttp.responseText.indexOf("ERROR: ") !== -1 207 || xmlHttp.responseText.indexOf("<Error>") !== -1) 208 { 209 var errorMsg = "callingFunction Failed with"; 210 if(xmlHttp.status == 200) { 211 errorMsg += " gsdlCGI error"; 212 } 213 errorMsg += ":\n" + xmlHttp.responseText; 214 215 console.log(errorMsg); 216 } 217 205 218 return xmlHttp.responseText; 206 219 } … … 208 221 // New, an Ajax Asynchronous Post method. 209 222 // For helpful links, see the urlPostSync() method above 210 this.urlPostAsync = function(scriptURL, params, callback ) {223 this.urlPostAsync = function(scriptURL, params, callback, errorCallback) { 211 224 var xmlHttp=false; 212 225 try { … … 264 277 xmlHttp.onreadystatechange=function() { 265 278 if(xmlHttp.readyState==4) { 266 callback(xmlHttp); // e.g. this might do: updatepage(xmlHttp.responseText); 279 // Original behaviour of this block was just this single line: 280 //callback(xmlHttp); // e.g. this might do: updatepage(xmlHttp.responseText) 281 282 var errorMsg = "callingFunction Failed with"; 283 284 // if a proper ajax error is detected, then call any errorCallback 285 if(xmlHttp.status != 200 && errorCallback != null) { 286 errorMsg += ":\n" + xmlHttp.responseText; 287 alert(errorMsg); 288 console.log(errorMsgPrefix); 289 290 errorCallback(xmlHttp); 291 } 292 293 // Check for silent errors (gsdl_cgi->generate_error causes a silent die) 294 // and alert user then call any errorCallback 295 else if(xmlHttp.responseText.indexOf("ERROR: ") !== -1 296 || xmlHttp.responseText.indexOf("<Error>") !== -1) 297 { 298 errorMsg += " gsdlCGI error:\n" + xmlHttp.responseText; 299 alert(errorMsg); 300 console.log(errorMsg); 301 302 if(errorCallback != null) { 303 errorCallback(xmlHttp); 304 } else { // if silent error and no errorCallback, resort to sole callback 305 callback(xmlHttp); 306 } 307 } 308 309 else { 310 // if either success, Or error status but there's no error callback, 311 // or if no silent die on error, then call default callback 312 callback(xmlHttp); // e.g. this might do: updatepage(xmlHttp.responseText); 313 } 267 314 } 268 315 } -
main/trunk/greenstone3/web/interfaces/default/js/javascript-global-functions.js
r38234 r38238 555 555 //var xml = $.parseXML(response); 556 556 //console.log(xml); 557 558 559 // Handle the otherwise silent die statement of gsdl_cgi->generate_error(), 560 // forcing the errorResponseFunction route in such a case 561 if(response.indexOf("ERROR: ") !== -1 || response.indexOf("<Error>") !== -1) { 562 if(errorResponseFunction != null) { 563 console.log("(" + callingFunction + ") Failed with gsdlcgi error:\n" + response); 564 errorResponseFunction(response); 565 } else { 566 alert("(" + callingFunction + ") Failed\n" + response); 567 console.log("(" + callingFunction + ") Failed\n" + response); 568 } 569 570 } 557 571 558 if(successResponseFunction != null) {572 else if(successResponseFunction != null) { 559 573 //console.log("XXXX callMetaServer - Got response: " + response); 560 574 successResponseFunction(response); … … 563 577 .fail(function(response) { 564 578 if(errorResponseFunction != null) { 565 errorResponseFunction(response); 579 console.log("(" + callingFunction + ") Failed\n" + response); 580 errorResponseFunction(response); 566 581 } else { 567 console.log("(" + callingFunction + ") Failed"); 582 alert("(" + callingFunction + ") Failed\n" + response); 583 console.log("(" + callingFunction + ") Failed\n" + response); 568 584 } 569 585 }); … … 584 600 585 601 if(async_setting) { 586 gsapi.urlPostAsync(url, params, successResponseFunction );602 gsapi.urlPostAsync(url, params, successResponseFunction, errorResponseFunction); 587 603 } else { 588 604 ajaxResponse = gsapi.urlPostSync(url, params); 589 ajaxResponse = ajaxResponse;605 //ajaxResponse = ajaxResponse; 590 606 } 591 607 -
main/trunk/greenstone3/web/interfaces/default/js/user_comments.js
r38237 r38238 461 461 var result = (data.responseText) ? data.responseText : data; 462 462 463 /* 463 464 // check for gsdl_cgi->generate_error() result, which ends up in a silent die statement 464 465 // unless we look for it in the "success" result, in the form of a message starting … … 468 469 return; 469 470 } 471 */ 470 472 471 473 //console.log("@@@ Done removing metadata:\n" + result);
Note:
See TracChangeset
for help on using the changeset viewer.