Skip to Content
avatar image
Former Member

Fiori QuickStartApplication: Load data from cross browser domain issue

I've setup a QuickStartApplication in the WebIDE and now I'm trying to get some JSON data from a remote repository that I want to display.
I'm struggling with the async AJAX call, because based on definition, if you're requesting data by cross-browser-domains, the Ajax setting async:false; will be ignored. Having that, the script (model/models.js) where I'm trying to load the data returns the model already but the data are still not available. Thus, I can not display anything in my view.

Any thoughts on this issue? How can I wait for the data before proceed?
In the example below, the data in the loadRepositoryModel function are still not available so that oModel.setData(data); tries to set "undefined".

], function(JSONModel) {
	"use strict";
	return {

	ajaxCallToCMISRepository: function() {"Entering ajaxCallToCMISRepository");
			var resultObjects = "({})";
			var alfUser = "guest";
			var alfPass = "guest";
	    	var alfURL = "https://myserver:8443/repo/1.1/dev/root/area/51";"Load JSON from Repository " + alfURL);
			var method = "GET";"Before AJAX CALL");
				type: method,
				url: alfURL,
				async: false,
				data: "{}",
				crossDomain: true,
				dataType: "jsonp",
				beforeSend: function (xhr){ 
					xhr.withCredentials = true;
				    xhr.setRequestHeader("Authorization", "Basic " + btoa(alfUser + ":" + alfPass)); 
				success: function (response){
			    	var jsonObjects = response["objects"];
			    	var countObjects = response["numItems"];
			    	for(var i = 0; i< countObjects; i++){
			    		var property = jsonObjects[i]["object"]["properties"];
			    		var propertyNameValue = property["cmis:name"]["value"];
					resultObjects = jsonObjects;"Return SUCESS of AJAX!");
				error : function (xhr, status, error) {"ERROR: " + xhr);"ERROR: " + status);"ERROR: " + error);
					var keys = $.map(xhr, function(item, key) {"EE: " + key +  " ==> " + item);
			return resultObjects;
		loadRepositoryModel: function() {"Entering loadRepositoryModel in model.js)");			
			var data = this.ajaxCallToCMISRepository();"------------------------------------ >>" + data);
			//"data:" + JSON.stringify(data));
	    	oModel = new sap.ui.model.json.JSONModel();
			return oModel;
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers