Help me find a bug. There is a table:
<table> <thead> <tr> <th>Username</th> <th>Role</th> <th>First name</th> <th>Last name</th> <th>Email</th> <th>Notes</th> <th>Active State</th> </tr> </thead> <tbody id="user-list"> <script id="user-records" type="text/x-handlebars-template"> {{#each user}} <tr> <td>{{username}}</td> <td>{{role}}</td> <td>{{firstName}}</td> <td>{{lastName}}</td> <td>{{email}}</td> <td>{{notes}}</td> <td>{{activeState}}</td> </tr> {{/each}} </script> </tbody> </table> Template:
var USER_METHOD ={ handlerData:function(resJSON){ var templateSource = $("#user-records").html(), template = Handlebars.compile(templateSource), studentHTML = template(resJSON); $('#user-list').html(studentHTML); }, loadUserData : function(){ $.ajax({ url:"/users", method:'get', success:this.handlerData }) } }; $(document).ready(function(){ USER_METHOD.loadUserData(); }); Well, the request itself:
@RestController @RequestMapping("/users") public class UsersController { @Autowired private UserRepository repo; @RequestMapping(method=RequestMethod.GET) public List<User> getAll() { return repo.findAll(); } } Via Postman, the result is as follows:
[ { "id": 1, "username": "admin", "password": "1234", "role": "ADMIN", "firstName": "alex", "lastName": "тест", "email": "alex@test.com", "notes": "test notes", "activeState": 1 } ] The problem is that the content in the table is not displayed and there are no errors in the browser either. Help me find what's wrong. Thank.