showing results for - "vuejs get data fromo ajax"
Paulette
28 May 2020
1<script type="text/javascript">
2var ItemsVue = new Vue({
3    el: '#Itemlist',
4    data: {
5        items: []
6    },
7    mounted: function () {
8        var self = this;
9        $.ajax({
10            url: '/items',
11            method: 'GET',
12            success: function (data) {
13                self.items = JSON.parse(data);
14            },
15            error: function (error) {
16                console.log(error);
17            }
18        });
19    }
20});
21</script>
22
23<div id="Itemlist">
24    <table class="table">
25        <tr>
26            <th>Item</th>
27            <th>Year</th>
28        </tr>
29        <tr v-for="item in items">
30            <td>{{item.DisplayName}}</td>
31            <td>{{item.Year}}</td>
32        </tr>
33    </table>
34</div>