prime
prime

Reputation: 351

Create List of Items in Jquery

I am working on VS 2013 Cordova App . I want to create new list of items by jquery . here is my Html code :

<div class="body" >
    <ul class="list list-messages" id="list">
    </ul>
</div>

And here is my js code :

<script>
    $(document).ready(function () {
        $.ajax({
            type: 'Get',
            url: 'http://41.128.183.109:9090/api/data/getalllocations',
            success: function (data) {
                $("#list").empty();
                for (var i = 0; i < data.length; i++) {
                    $("#list").append('<li class="list-message" data-ix="list-item"><a class="w-clearfix w-inline-block" href="chat.html" data-load="1"><div class="w-clearfix column-left"><div class="image-message"><img src="images/128.jpg"></div></div><div class="column-right"><div class="message-title">James White</div><div class="message-text">Hey dude! We are waiting for you at the main station, we will meet you near to....</div></div></a></li>');

                }
            }
        });
    });
</script>

But it dosen't work with me , Please advice

Upvotes: 1

Views: 1399

Answers (1)

Jordan Lowe
Jordan Lowe

Reputation: 368

For starters you have two #list ids, try removing the id from the div.

You should never had two id's the same.

Furthermore, change the append and empty to the class ".list" and remove both ID's

Upvotes: 1

Related Questions