原生Ajax請求引數
阿新 • • 發佈:2021-11-22
首先先寫一個json檔案宣告內容
{
var students=cls.student; for (let index = 0; index < students.length; index++) { const stu = students[index]; $(".data tbody").append("<tr><td>"+stu.id+"</td><td>"+stu.name+"</td></tr>"); } }else{ console.log(data.msg); } }) //url [data] success [dataType] //$.post() }) 最後顯示內容 body的內容: <legend></legend> <table class="data"> <thead> <td>id</td> <td>name</td> </thead> <tbody> <!-- <tr></tr> --> </tbody> </table> <legend></legend> <table class="data"> <thead> <td>id</td> <td>name</td> </thead> <tbody> <!-- <tr></tr> --> </tbody> </table>
// 先判斷是否是200
// 獲取資料
// 返回資料
var students=cls.student; for (let index = 0; index < students.length; index++) { const stu = students[index]; $(".data tbody").append("<tr><td>"+stu.id+"</td><td>"+stu.name+"</td></tr>"); } }else{ console.log(data.msg); } }) //url [data] success [dataType] //$.post() }) 最後顯示內容 body的內容: <legend></legend> <table class="data"> <thead> <td>id</td> <td>name</td> </thead> <tbody> <!-- <tr></tr> --> </tbody> </table> <legend></legend> <table class="data"> <thead> <td>id</td> <td>name</td> </thead> <tbody> <!-- <tr></tr> --> </tbody> </table>