ajax的回調函數(done,fail,always)
觀看代碼:
1 $.ajax({ 2 type: "post",//請求的類型 3 url: "/book/detail?act=lsid",//請求路徑帶參數 4 data: {id: id} 5 }).done(function (da) { 6 $("#bookId").val(da.id); 7 $("#bookname").val(da.name); 8 $("#bookprice").val(da.price); 9 $("#bookauthor").val(da.author.trim()); 10 $("#bookpress").val(da.press.trim()); 11 }).fail(function (xhr, textStatus, errorThrown) { 12 alert("原生ajax:" + xhr + textStatus + "詳細錯誤:" + errorThrown); 13 }).always(function () { 14 console.log("完成任務流程結束"); 15 })