Home Display some simple data in HTML
Reply: 0

Display some simple data in HTML

user1284
1#
user1284 Published in April 22, 2018, 10:11 pm

activeUsers.getUsers() returns a list with the online users in my app.

I want to display it in my HTML but I have no idea how to do this. I'm getting error 404 on my ajax request yet if I put a breakpoint in my controller it shows the list of online users.

Any help??

Controller

  @RequestMapping(value = "/loggedUsers", method = RequestMethod.GET)
public String getLoggedUsers(Model model) {
    model.addAttribute("loggedUsers", activeUsers.getUsers());
    return "loggedUsers";
}

AJAX

$(document).ready(function () {

//get loggedUsers
$.ajax({
    url: '/loggedUsers',
    type: 'get',
    success: function (loggedUsers) {
        console.log(loggedUsers);
    }
});
});

HTML

<div id="sidebar-right" class="visible">
<ul class="sidebar-nav">
    <li id="dashboard">
        <a href="dashboard">
            <c:forEach var="loggedUser" items="${loggedUsers}">
                <span class="menu-title">${loggedUser}</span>
            </c:forEach>
        </a>
    </li>
</ul>

the console log returns:

error 404

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.313532 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO