Quantcast
Channel: Free community support — DataTables forums
Viewing all articles
Browse latest Browse all 35273

Can't get all row data

$
0
0

Hello!
First i have to say, im new to data tables and javascript at all. And thats my first project i'm using it.
How can i get all data from the table in an array?
This is what i have tried:

oTable = $('#dataTable').DataTable();
getAllMarker();
var rows = oTable.rows().data();
alert(rows.length);

alert always return 0 but my table is populated with values. This is done in the getAllMarker() Method.

function getAllMarker(){

        $.ajax({
            type: "POST",
            url: "marker.php",

            //IMPORTANT: set marker_table depending on current markerobject
            data:{function:"getAllMarker" },
            dataType: 'json',
            success: function(s){
                console.log(s);
                oTable.clear();
                for(var i = 0; i < s.length; i++) {
                    var space = " ";

                    oTable.row.add([
                        s[i][0],
                        s[i][0], //id
                        s[i][1], //attribut
                        s[i][11], //rating
                        s[i][12], //comment
                        s[i][4], //latitude
                        s[i][5], //longitude
                        s[i][6], //street
                        s[i][7], //city
                        s[i][8], //zip
                        s[i][2], //creation_time
                        s[i][3], //update_time
                        s[i][9]+=space+=s[i][10], //creator
                    ]).draw();;

                } // End For
            },
            error: function(e){
                console.log(e.responseText);

            }
        });


    }

Hope anyone can help me.


Viewing all articles
Browse latest Browse all 35273

Trending Articles