function clickFunc(id) { var params = new Array(); params.push({ name: "id", value: id}); Post("/Action/method", params);}function Post(URL, PARAMTERS ...
function clickFunc(id) {
var params = new Array();
params.push({ name: "id", value: id});
Post("/Action/method", params);
}
function Post(URL, PARAMTERS) {
//創建form表單
var temp_form = document.createElement("form");
temp_form.action = URL;
//如需打開新視窗,form的target屬性要設置為'_blank'
temp_form.target = "_self";
temp_form.method = "post";
temp_form.style.display = "none";
//添加參數
for (var item in PARAMTERS) {
var opt = document.createElement("textarea");
opt.name = PARAMTERS[item].name;
opt.value = PARAMTERS[item].value;
temp_form.appendChild(opt);
}
document.body.appendChild(temp_form);
//提交數據
temp_form.submit();
}