//封装post时候,表单中所有具有name数据的表单元素的值,并返回“n=1&p=a”function serialize(formid) { var arr = []; var ipts = document.getElementById(formid).getElementsByTagName('input'); for (var i = 0; i < ipts.length; i++) { if (ipts[i].type=='text') { if (ipts[i].name) { arr[arr.length] = ipts[i].name + '=' + ipts[i].value; } } } return arr.join('&');}