1、在现有的formID下动态添加属性
function formAppendSubmit(){
var form1=$('#form1');
var tmpInput=$("");
tmpInput.attr("value", "xxxxx");
form1.append(tmpInput);
form1.submit();
}
2、动态生成form,动态添加属性并提交
function(event){
form = $("")
form.attr('action',action)
form.attr('method','post')
input1 = $("")
input1.attr('value','input1 value')
input2 = $("")
form.append(input1)
form.append(input2)
form.appendTo("body")
form.css('display','none')
form.submit()
}
3、使用formData,动态添加属性并提交
function postData() {
var data = new FormData();
data.append("title", 'xxxx');
data.append("author", 'dfdfd');
$.ajax({
type: "POST",
dataType: "html",
url: www.baidu.com,
data: data,
success: function (data) {
},
error: function(data) {
}
});
}