Code demo bất đồng bộ & callback JS Run

Code: Html | Auth: 03cd82
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
    <h1>Dữ liệu lấy trên Server</h1>
    <h2>Nội dung: <span id="msg"></span></h2>

    <table border="1" cellpadding="10">
        <thead>
        <tr><th>STT</th> 
            <th>Tên sản phẩm</th>
        </tr>
        </thead>
        <tbody>

        </tbody> 
    </table>
    <h3>Hết</h3>

    <script>
        var url = 'http://son.snvn.net/a.php';

        fetch(url,{
            method:"GET"
        }).then(function(rs){
            return rs.json(); // phần này xử lý chuyển đổi dữ liệu trả về thành json
        })
        .then(function (data){
            // đến đây có dữ liệu dạng json, có thể dùng làm mọi việc.
            // duyệt mảng 
            console.log(data);

            // document.querySelector("#msg").innerHTML = data[0];
        }); 
 
    </script>
</body>
</html>