Bonjour à vous,

Voici un extrait de code qui fonctionne très bien depuis (MVC c#)
Je me sers d'un exemple en me servant de la base de données Northwind.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
 <script src="~/Scripts/jquery-3.6.0.min.js"></script>
 
    <script type="text/javascript">
 
        $(document).ready(function () {
 
            $("#CategoryType").change(function () {
                var selectedItem = $(this).val();
                $("#tblProducts tbody tr").remove();
                    $.ajax({
                            type: 'get',
                            url: '@Url.Action("RetourListe")',
                        dataType: 'json',
                            data: { id: selectedItem },
                        success: function (data) {
                            var items = '';
                            $.each(data, function (i, item) {
 
                                var rows = "<tr>"
                                + "<td>" + item.ProductID + "</td>"
                                    + "<td>" + item.ProductName + "</td>"
                                + "<td>" + item.QuantityPerUnit + "</td>"
                                + "<td>" + item.UnitPrice + "</td>"
                                + "<td>" + item.UnitsInStock + "</td>"
                                + "<td>" + item.ReorderLevel + "</td>"
                                + "</tr>";
                                $('#tblProducts tbody').append(rows);
 
                             });
 
                        },
                        error: function (ex) {
                            var r = jQuery.parseJSON(response.responseText);
                            alert("Message: " + r.Message);
                            alert("StackTrace: " + r.StackTrace);
                            alert("ExceptionType: " + r.ExceptionType);
                        }
                    });
               return false;
            })
        });
 
    </script>
J'obtiens un tableau du plus belle effet, mais cependant, lorsque je vérifie le code source de la page j'ai uniquement ceci :
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
   <table id="tblProducts" class="table table-striped">
            <thead>
                <tr>
                    <th scope="col">ProductID</th>
                    <th scope="col">ProductName</th>
                    <th scope="col">QuantityPerUnit</th>
                    <th scope="col">UnitPrice</th>
                    <th scope="col">UnitsInStock</th>
                    <th scope="col">ReorderLevel</th>
                </tr>
            </thead>
            <tbody></tbody>
        </table>
Il n'y à rien dans tbody !!!
Est-ce normal, y a t'il moyen de l'afficher en "dur" pour voir apparaître le résultat dans le code source ?

Merci pour votre réponse..