简体   繁体   中英

How to use AJAX for GET requests in Totaljs?

I am using the below code. The AJAX GET is returning status code 500. I am not sure what is missing.

<div class="container pt-1" id="usersList">
    <h5>List of Users</h5>
    <div data-bind="users.list__template">
        <ul class="list-group">
        @{foreach user in model}
        <a class="userList" href=/@{user._id}> <li class="list-group-item">@{user.name}</li></a>
        @{end}
        </ul>
    </div>
</div> 

$('#usersListLink').on('click', (event) => {
    event.preventDefault();
    AJAX('GET /usersList', 'items --> usersList.items');
    $("#homepage").hide();
    $("#usersList").show();
    $("#addUser").hide();
});

It's hard to say just from what you shown. But on the controllers check the route, it looks it could be flag with some role permits.

F.route('/uesrslist', get_platform, ['authorize', '@role']);

This could be different depending on how your project is created.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM