@@ -126,10 +126,12 @@ api.content.getParam = function (pKey) {
126
126
* @param {* } pSelectorContainer
127
127
* @param {* } pRelativeURL
128
128
* @param {* } pParams
129
+ * @param {* } pAppend
129
130
*/
130
- api . content . load = function ( pSelectorContainer , pRelativeURL , pParams ) {
131
+ api . content . load = function ( pSelectorContainer , pRelativeURL , pParams , pAppend ) {
131
132
// Default parameters
132
133
pParams = pParams || { } ;
134
+ pAppend = pAppend || false ;
133
135
134
136
// Validate the Relative URL
135
137
var uri = new URI ( pRelativeURL ) ;
@@ -146,9 +148,14 @@ api.content.load = function (pSelectorContainer, pRelativeURL, pParams) {
146
148
async : false ,
147
149
success : function ( response ) {
148
150
api . content . params = pParams ;
149
- $ ( pSelectorContainer ) . empty ( ) . html ( response ) . promise ( ) . done ( function ( ) {
150
- api . content . params = { } ;
151
- } ) ;
151
+ if ( pAppend )
152
+ $ ( pSelectorContainer ) . append ( response ) . promise ( ) . done ( function ( ) {
153
+ api . content . params = { } ;
154
+ } ) ;
155
+ else
156
+ $ ( pSelectorContainer ) . empty ( ) . html ( response ) . promise ( ) . done ( function ( ) {
157
+ api . content . params = { } ;
158
+ } ) ;
152
159
}
153
160
} ) ;
154
161
} ;
@@ -311,22 +318,34 @@ api.ajax.callback = function (pFunction, pResponse, pParams) {
311
318
312
319
/**
313
320
* Load a configuration file
314
- * Use Javascript rather than JQuery because the configuration must load synchronously before $(document).ready
315
- * @param {* } url
316
- * @param {* } callback
321
+ * @param { * } pUrl
322
+ * @param {* } pCallback
323
+ * @param {* } pAjaxParams
317
324
*/
318
- api . ajax . config = function ( url , callback ) {
319
- var xobj = new XMLHttpRequest ( ) ;
320
- xobj . overrideMimeType ( "application/json" ) ;
321
- xobj . open ( 'GET' , url , false ) ;
322
- xobj . onreadystatechange = function ( ) {
323
- if ( xobj . readyState == 4 && xobj . status == "200" ) {
324
- callback ( xobj . responseText ) ;
325
- } else {
326
- console . log ( "Internal Error: the configuration file \"" + url + "\" is missing or invalid." ) ;
325
+ api . ajax . config = function ( pUrl , pCallback , pAjaxParams ) {
326
+ // Default AJAX parameters
327
+ pAjaxParams = pAjaxParams || { } ;
328
+ pAjaxParams . method = pAjaxParams . method || 'GET' ;
329
+ pAjaxParams . dataType = pAjaxParams . dataType || 'json' ;
330
+ pAjaxParams . jsonp = pAjaxParams . jsonp || false ; // Fix for "??" JQuery placeholder
331
+ pAjaxParams . timeout = pAjaxParams . timeout || 60000 ;
332
+ pAjaxParams . async = pAjaxParams . async || false ;
333
+
334
+ ajaxParams = {
335
+ url : pUrl ,
336
+ success : function ( response ) {
337
+ pCallback ( response ) ;
338
+ } ,
339
+ error : function ( jqXHR , textStatus , errorThrown ) {
340
+ // Log the issue rather than popping it in a Bootstrap modal because the document may not be ready yet
341
+ console . log ( "An Internal Server has occurred: the configuration file \"" + url + "\" is missing or invalid." ) ;
327
342
}
328
343
} ;
329
- xobj . send ( null ) ;
344
+
345
+ // Merge ajax parameters
346
+ $ . extend ( ajaxParams , pAjaxParams ) ;
347
+ // Run the Ajax call
348
+ $ . ajax ( ajaxParams ) ;
330
349
} ;
331
350
332
351
/*******************************************************************************
0 commit comments