0
votes

I am trying to display JSON data on a list but my javascript code gets stuck in the middle of wlCommonInit() function.

function wlCommonInit(){
        WL.Logger.debug("inside the wlcommoninit");
        busyIndicator = new WL.BusyIndicator('AppBody');
        var $list = $("ul#myList");
        $list.append('<li> ' + "resrere" + 
        '</li>');

        getData();

        $list.append('<li> ' + "resrere" + 
        '</li>');
    }

    function getData() {
        $.mobile.showPageLoadingMsg();
        WL.App.overrideBackButton (function(){WL.App.close();});
    var invocationData = {
            adapter : 'StudentInfo',
            procedure : 'getStudentInfos'

        };

    WL.Client.invokeProcedure(invocationData,{
        onSuccess : loadFeedsSuccess,
        onFailure : getDataFailure,

    });
    }

    function loadFeedsSuccess(result){
        if (!result || !result.invocationResult || !result.invocationResult.items || result.invocationResult.items.length == 0)
            alert("Could not retrieve feeds");  

        feeds = result.invocationResult.items;
        $("ul#myList").empty();
        for (var i=0; i<feeds.length; i++){
            var dataItem = feeds[i];
            var listItem = $("<li>" + dataItem.question + "</li>");
            $("ul#myList").append(listItem);                 
           }

    }

In this code, it sticks at getData(); it displays the first "resrere" but it does not display second "resrere". I can not find the problem, so I can not create any solution. Thanks for your help.

1

1 Answers

1
votes

items should be resultSet.
Tested locally and verified to work after the below changes.

Change this:

if (!result || !result.invocationResult || !result.invocationResult.items || result.invocationResult.items.length == 0)

To This:

if (!result || !result.invocationResult || !result.invocationResult.resultSet || result.invocationResult.resultSet.length == 0)

And this:

feeds = result.invocationResult.items;

To this:

feeds = result.invocationResult.resultSet;