jQuery ajax中使用serialize()方法提交表單數據示例
來源:懂視網
責編:小采
時間:2020-11-27 22:52:14
jQuery ajax中使用serialize()方法提交表單數據示例
jQuery ajax中使用serialize()方法提交表單數據示例:jQuery ajax中數據以鍵值對(Key/Value)的形式發送到服務器,使用ajax提交表單數據時可以使用jQuery ajax的serialize() 方法表單序列化為鍵值對(key1=value1&key2=value2…)后提交。serialize() 方法使用標準的 URL-encoded 編碼
導讀jQuery ajax中使用serialize()方法提交表單數據示例:jQuery ajax中數據以鍵值對(Key/Value)的形式發送到服務器,使用ajax提交表單數據時可以使用jQuery ajax的serialize() 方法表單序列化為鍵值對(key1=value1&key2=value2…)后提交。serialize() 方法使用標準的 URL-encoded 編碼

jQuery ajax中數據以鍵值對(Key/Value)的形式發送到服務器,使用ajax提交表單數據時可以使用jQuery ajax的serialize() 方法表單序列化為鍵值對(key1=value1&key2=value2…)后提交。serialize() 方法使用標準的 URL-encoded 編碼表示文本字符串。下面是使用serialize()序列化表單的實例:
代碼如下:
$.ajax({
type: "POST",
url: ajaxCallUrl,
data: "Key=Value&Key2=Value2",
success: function(msg){alert(msg);}
});
ajax serialize():
代碼如下:
$.ajax({
type: "POST",
url:ajaxCallUrl,
data:$('#formID').serialize(),// 要提交的表單
success: function(msg) {alert(msg);}
});
實例:
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
jQuery ajax中使用serialize()方法提交表單數據示例
jQuery ajax中使用serialize()方法提交表單數據示例:jQuery ajax中數據以鍵值對(Key/Value)的形式發送到服務器,使用ajax提交表單數據時可以使用jQuery ajax的serialize() 方法表單序列化為鍵值對(key1=value1&key2=value2…)后提交。serialize() 方法使用標準的 URL-encoded 編碼