post发送数据 mypost input 改变事件
//name=或者 "&name=" + "123" + "&data=" + "slice" (可以获取) 服务器获取不到数据(先发送后加入请求头),加入 xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");也是 //"?name=" + "123" + "&data=" + "slice" (只能获取data) 服务器获取不到数据,加入 xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");也是 //"/?name=" + "123" + "&data=" + "slice" (只能获取data) 服务器获取不到数据,加入 xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");也是 that.mypostformdata('/Home/AddFile', "/?name=" + "123" + "&data=" + "slice", function (data) { console.log(data); start = JSON.parse(data).result; });
get 发送数据 (没有测试)
function submit() { document.getElementById('form1').action = "/Backstage/GroupManage/List/"; var type = document.getElementById("Type").value; var type1 = document.getElementById("Type1").value; var search = document.getElementById("search").value; console.log("type" + type + "type1" + type1 + "search" + search); console.log($("#form1").serialize()); //输出字符串; //Type=5&Type1=7&search= ////执行函, post请求 //var posturl = "/Backstage/GroupManage/List"; //upload.myget(posturl, formData, function (data) { // var objdata = JSON.parse(data); // layer.msg(objdata.msg); // setTimeout(function () { // window.location.href = window.location.href; // }, 1000); //layer.closeAll('dialog'); //加入这个信息点击确定 会关闭这个消息框 //} //); // document.getElementById("form1").submit(); }
var formData = new FormData();
formData.append("sets", sets);
var posturl = "/123/456/789";
post(posturl, formData);
var b1 = false; function post(posturl, formData) { if (b1 == false) { b1 = !b1; upload.mypost(posturl, formData, function (data) { var objdata = JSON.parse(data); layer.msg(objdata.msg); if (objdata.success) { setTimeout(function () { window.location.href = window.location.href; }, 1000); //layer.closeAll('dialog'); //加入这个信息点击确定 会关闭这个消息框 } setTimeout(function () { b1 = !b1; }, 500); }); } }
var file001 = document.getElementById("file001"); file001.onchange = function () { var that = this; var span = that.parentNode.getElementsByTagName("span"); if (this.files.length>0) { span[0].innerHTML = this.files[0].name; return; } span[0].innerHTML = ""; } document.getElementById("btn001").onclick = function () { file001.click(); }