Can anyone help to fetch data from .json file and view it in xml? thank you
here the code
var args = arguments[0] || {}; var apiHelper = require('apiHelper'); var listNews = Alloy.Collections.groupList; //get all categories in news var unique = {}; var categories = []; var selectedCategoryIndex = 0; var itemPerPage = 10; var currentPage = 0; var maxPage = 0; var result = []; function getAllNews(){ if (Ti.Network.online){ console.log('calling get all group 1'); Alloy.Globals.showActivityIndicator(); console.log('calling get all group 2'); apiHelper.APIGetRequest(Alloy.Globals.ApiURL + "/getGroupList", function(e) { //if success console.log('calling get all group 3'); var items = []; console.log('response get news : ' + this.responseText); var result = JSON.parse(this.responseText); for(var i = 0; i < result.length; i++){ var data = { userId : {real : result[i].userId}, groupName : { text : result[i].groupName} }; items.push(data); console.log('calling get all group 4'); } $.newsList.sections[0].setItems(items); if (OS_ANDROID) { var toast = Ti.UI.createNotification({ message : "News Updated", duration : Ti.UI.NOTIFICATION_DURATION_SHORT }); toast.show(); } Alloy.Globals.hideActivityIndicator(); }, function(e){ //if error Alloy.Globals.hideActivityIndicator(); }); } else{ if (OS_ANDROID) { var toast = Ti.UI.createNotification({ message : "Can't connect to the internet", duration : Ti.UI.NOTIFICATION_DURATION_LONG }); toast.show(); } else { Alloy.Globals.showMessageBox('Error', "Can't connect to the internet", 'OK', null); } } } getAllNews(); // function reload(){ // getAllNews(); // $.refresh.setRefreshing(false); // }JSON data output
{ "message": "Data berhasil didapatkan", "response": "success", "groupList": [ { "id": 60, "active": 1, "userId": 21, "groupName": "addgroupname", "createdBy": "admin", "creationDate": 1423560031070, "lastUpdatedBy": null, "lastUpdatedDate": null }, etc...thanks