http://www.cnblogs.com/_franky/archive/2010/05/08/1730437.html
下面是例子
function test(url, obj) {
if($("#myForm").size() == 0){
$("body").append("<form id='myForm'></form>");
}else{
$("#myForm").empty();
}
var data = {};
if(obj != undefined){
for(var o in obj) {
//遍历的作用,var obj = {
// '1' : 1,
// '_' : 2,
// '0' : 4,
// 'c' : 1,
//},其中o就是1,——,0,c;obj[o]是后面的1,2,4,1
if(obj[o] != null) {
var inputTag = ""
if(obj[o] != ""){
inputTag = "<input type='hidden' name="+ o +" value='"+ obj[o] +"'/>";
}else{
inputTag = "<input type='hidden' name="+ o +" />"
}
$("#myForm").append(inputTag);
}
}
data = $("#myForm").serialize();
}
}