var formElement = document.getElementById("buildingform");
var fd = new FormData(formElement);
$.ajax({
//几个参数需要注意一下
type: "POST",//方法类型
dataType: "json",//预期服务器返回的数据类型
url: "{:url('Buildingmanager/add_building')}",//url
data:fd,
processData: false,// 告诉jQuery不要去处理发送的数据(必须设置) 重点参数
contentType: false, // 告诉jQuery不要去设置Content-Type请求头(必须设置) 重点参数
success: function (result) {
if (result.code == 1) {
window.location.href="/admin/buildingmanager/building_list";
}else{
layer.msg(result.msg);
}
},
error : function() {
alert("异常!");
}
});
重点::一定要设置
processData: false,// 告诉jQuery不要去处理发送的数据(必须设置) 重点参数
contentType: false, // 告诉jQuery不要去设置Content-Type请求头(必须设置) 重点参数