JS中在A标签超链接点击时出发模拟POST请求的代码段。
思路是创建虚拟表单并提交,然后销毁表单。
function a_post(PARAMS) {
var temp = document.createElement("form");
temp.id = "temp";
temp.method = "post";
temp.style.display = "none";
for (var x in PARAMS) {
var opt = document.createElement("textarea");
opt.name = x;
opt.value = PARAMS[x];
temp.appendChild(opt);
}
document.body.appendChild(temp);
$(temp).submit(function() {
window.art.artDialogConfirm.direct_post({
data_form_id: 'temp',
backUrl: '{{url u="/index"}}',
show_success_info: true
});
return false;
});
$(temp).submit();
document.body.removeChild(temp);
}
本文介绍如何在JavaScript中利用A标签实现模拟POST请求的方法,通过创建并提交虚拟表单来达到目的,提交后销毁表单。

2491

被折叠的 条评论
为什么被折叠?



