Datatable funktioniert nicht auf ajax-call

Benutze ich Datatable in meine web-Anwendung.
Folgende ist meine einfachen code, der die Daten über ajax.

<script>
    $(document).ready(function() {
        $('#mytable').DataTable();
    } );
</script>

<body>
  <h2>AJAX SELECT</h2><hr>
  <div align="center">
    Select Team :
    <select name="select" id ='teamSelect'>
        <option value="">Select Value</option>
        <option value="op2">Company 1</option>
    </select>
  </div>
  <div id='tableContainer' align="center"></div>

 <script>
    $(function() {
        $("#teamSelect").bind("change", function() {
            $.ajax({
                type: "GET", 
                url: "getData.php",
                "dataSrc": "tableData",
                success: function(html) {
                    $("#tableContainer").html(html);
                }
            });
        });

    });
</script>

und Getdata.php Code

<table id="mytable" class="display" cellspacing="0" width="50%">
    <thead>
    <tr>
        <th>First name</th>
        <th>Last Name</th>
        <th>Email</th>
    </tr>
</thead>
<tbody>
    <tr>
        <td>Airi Satou</td>
        <td>Accountant</td>
        <td>Tokyo</td>
    </tr>
    <tr>
        <td>Brielle Williamson</td>
        <td>Integration Specialist</td>
        <td>New York</td>
    </tr>
    <tr>
        <td>Herrod Chandler</td>
        <td>Sales Assistant</td>
        <td>San Francisco</td>
    </tr>
    <tr>
        <td>Rhona Davidson</td>
        <td>Integration Specialist</td>
        <td>Tokyo</td>
    </tr>
</tbody>

Ich Link Jquery datatable css-und js-beide.aber immer noch Es Rückkehr-Ausgang als normalen HTML-Tabelle.
Keine Konsole Fehler gegründet.
Ich brauche die Daten in der datatable. Also, wie kann ich das bekomme.

und habe ich auch getestet datatable in index.php Seite. Es funktioniert ganz gut.

InformationsquelleAutor TarangP | 2017-09-19
Schreibe einen Kommentar