jquery构造from提交表单

时间:2022-12-02 18:41:17
var pams = [];
var customer = encodeURIComponent($.trim($('#customer').val()));
var age = $('#age').val();
var gender = $('#gender').val();
pams.push($('<input>', {name: 'age', value: age}));
pams.push($('<input>', {name: 'customer', value: customer}));
pams.push($('<input>', {name: 'gender', value: gender}));
pams.push($('<input>', {name: 'backurl', value: encodeURIComponent('/user/new')}));
$('<form>', {
    method: 'post',
    action: '/user/add.do'
}).append(pams).submit();