0

When I display data from console, I get this:

0: {smname: "thor", sim: "9976680249", pondo: "10"}
1: {smname: "asd", sim: "9999999999", pondo: "0"}
2: {smname: "asd", sim: "4444444444", pondo: "0"}
3: {smname: "bcvb", sim: "7867896786", pondo: "0"}
4: {smname: "fgdg", sim: "5464564564", pondo: "0"}
5: {smname: "throw", sim: "zxcxxxxxxx", pondo: "0"}
length: 6

I have problem with JS, it wont display to my HTML table. Here's my JS:

     let a = 1;
        if(data.includes("NO PIN")){
            alert(data);
        }else{
            $("#aname").text("");
            $("#asim").text("");
            $("#pinpass").text("");
            console.log(data);
            $("#divaddnew").html("");

            a = data.length;
            for(let x=0; x < data.length; x++){
                let agentsz = 
                `<tr class="clr">
                    <td align=center>${data[x].smname}</td>
                    <td align=center>${data[x].sim}</td>
                    <td align=center>${data[x].pondo}</td>
                </tr>`
                $("#agentss").after(agentsz); 
                a--;
            }
        }

and here's my HTML table:

     <tbody>
            <tr id="#agentss">

            </tr>
     </tbody>
kwestionable
  • 496
  • 2
  • 8
  • 23
  • Thats why the [datatables](https://datatables.net/) plugin made for – User863 Sep 26 '19 at 14:28
  • 1
    Possible duplicate of [Create HTML table from JavaScript object](https://stackoverflow.com/questions/17684201/create-html-table-from-javascript-object) – User863 Sep 26 '19 at 14:29

1 Answers1

2

Try removing the "#" from the id in your html:

 <tbody>
        <tr id="agentss">

        </tr>
 </tbody>

(but leave it in your jquery selectors)

Clark
  • 137
  • 1
  • 2
  • 6