Ajax
Ajax
- Update a web page without reloading the page
- Send data to a server - in the backgroun
$.ajax({
url: '', // url位置
type: 'post', // post/get
data: { querytag: data }, // 輸入的資料
error: function (xhr) { }, // 錯誤後執行的函數
success: function (response) { }// 成功後要執行的函數
});
1.輸出時卻是一個 Object
2.先return result, result= undefind = > $.ajax 方法預設的 async:true 啟動非同步方法,也就是說並不會等 $.ajax 執行完成才 return ,而是一開始就直接 return 了
===> async: false //啟用同步請求
3.傳遞一個 arr 的陣列至 Server 端,發現 Server 端的參數一直會是 null
===> (1.) 設成 post (2.) tradition:true //傳遞陣列需設定
4. Ajax 在瀏覽器上一直瘋狂的抓到舊的資料
===> cache: true ----> ( $.ajaxSetup({ cache: false }); )