How to load data from external json in v5?

Hello,

I studied the sample app called Urban Dictionary on how json load into the app.
it uses template7 to load and compile json.
The problem is that, the sample app is probably in v4 or older.
I see a lot of differences in v5. So i get a little confused

Can anyone give me a working sample in v5? here are the tasks i need to learn

load external json file (or php but encoded as json)
display on the app thru media list for example.

Thank you so much for those you can answer.
-Sean

You can use app.request and virtual-list.

    app.request({
                    url: 'http:example.com',
                    method: 'POST',
                    dataType: 'XML',
                    crossDomain: true,
                    data: data, 
                    success: function (data, textStatus) {

                        //do something with data

                       });

                        // create virtual list with the data

var virtualList = app.virtualList.create({
                            // List Element
                            el: '.virtual-list',
                            cache: false,
                            // Pass array with items
                            items: items,
                            emptyTemplate: 'Nothing found.',
                            // List item Template7 template
                            itemTemplate: '<li class="btn-sucursales" id="id" >' + 
    '...'+
                                '</li>',
                        });
                    },
                    error: function (xhr, textStatus, errorThrown) {
             // do something on error
                    },
                });

Whatch this video https://youtu.be/Auo6YVK2nYY

1 Like