IBM Worklight - Unable to display data retrieved using SQL adapter

后端 未结 1 2086
醉梦人生
醉梦人生 2020-12-22 04:01

I am trying to fetch data from a database and display it in the app.
Below is my code. The invokation is doing well, but the data is not displayed.

sqlAd

相关标签:
1条回答
  • First, you need to change "Items":

    if (result.invocationResult.Items.length>0) 
            displayFeeds(result.invocationResult.Items);
    

    To "resultSet":

    if (result.invocationResult.resultSet.length>0) 
            displayFeeds(result.invocationResult.resultSet);
    


    Second, I've used the worklight_training database script Worklight provides in conjunction with your code snippets from the question. I've altered the displayFeeds function to this:

    function displayFeeds(items) {
        var ul = $('#itemsList'), i, li;
    
        for (i = 0; i < items.length; i += 1) {     
            // Create new <li> element and populate it
            li = $('<li/>').text(item.firstName);   
            // Append the <li> element to the <ul> element
            ul.append(li);      
        }
    }
    

    The end result was displaying the firstName values from the users table.
    You can then play with your JavaScript a bit more to display what you want from your database table...

    enter image description here

    BTW, as you can see... the console in Chrome Dev Tools does show something... which you claim in your case it does not. You need to figure that out.

    0 讨论(0)
提交回复
热议问题