SharePoint getting list and shown in HTML table

SharePoint getting list and shown in HTML table

Hey Guys,

i have a sharepoint list with some data and i want it to show in a html table.

i used this code to get the data Object

var readAll = function () {
    $.ajax(
            {
                url: _spPageContextInfo.webServerRelativeUrl +
                    "/_api/web/lists/getByTitle('')/items/" +
                    "?$select=Id, Title, pb_FirstName, pb_PhoneNumber" +
                    "&$orderby=Title,pb_FirstName, pb_PhoneNumber",
                type: "GET",
                headers: {
                    "accept": "application/json;odata=verbose",
                },
                success: function (data) {
                    console.log(data);
                },
                error: function (err) {
                    alert(JSON.stringify(err));
                }
            }
        );
};


$(document).ready(function () {
    readAll();
});


then i created a div with a table and put this code into

var readAll = function (data) {
    var html = [];
    html.push("<table><thead><tr><th>ID</th><th>First Name</th>" +
              "<th>Last Name</th><th>Phone</th></tr></table></thead>");

so the table is shown but how can i put the data into the table? i've tried it with something like this

var results = data;

    for (var i = 0; i < results; i++) {
        html.push("<tr><td>");
        html.push(data[i].ID);
        html.push("</td><td>");
        html.push(data[i].Title);
        html.push("</td><td>");
        html.push(data[i].pb_LastName);
        html.push("</td><td>");
        html.push(data[i].pb_PhoneNumber);
        html.push("</td><tr>");
    }

    html.push("</table>");
    $('.table').html(html.join(''));
}



hope u guys can help me