mui怎样快速获取提交表单值,像jquery的serialize那样

2025-04-13 04:00:53
推荐回答(2个)
回答1:

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);}
});

回答2:

你的表单元素(input、select、checkbox、radio之类)都没有写name属性,序列化的时候怎么知道要以什么名字向服务器提交??你服务器程序怎么知道以什么参数名去取值??