js post提交方法

function post(URL, PARAMS) {        
            var temp = document.createElement("form");        
            temp.action = URL;        
            temp.method = "post";        
            temp.style.display = "none";        
            for (var x in PARAMS) {        
                var opt = document.createElement("textarea");        
                opt.name = x;        
                opt.value = PARAMS[x];        
                // alert(opt.name)        
                temp.appendChild(opt);        
            }        
            document.body.appendChild(temp);        
            temp.submit();        
            return temp;        
        } 
post('url', {param1:value1,param2:value2,param3:value3,...});

猜你喜欢

转载自blog.csdn.net/boenwan/article/details/71535109