js post传值


一种是ajax传值,另一种是post传值,

ajax传值:

$.ajax({
url: "AjaxTxt/Fild.ashx?Name=duibi&dates=" suzkr"&tdds=" suztd”,
type: "post",
success: function (date) {
var u = $.parseJSON(date);

}

}):

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("input");
opt.name = x;
opt.value = params[x];
temp.appendChild(opt);
}
document.body.appendChild(temp);
temp.submit();
return temp;
}

//调用方法 如
 post('pages/statisticsJsp/excel.action', { html: prnhtml, cm1: 'sdsddsd', cm2: 'haha' });

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM