ajax返回数据不跳success
<form action="" onsubmit="post_data();return false;" id="formT" method="post" class="form-T">
form标签内加 onsubmit="post_data();return false;"
function post_data(){
$.ajax({
url: "",
type: "POST",
data: form,
dataType: "json",
success: function (res) {
alert(res.msg);
},
error:function(){
console.log("请求失败")
},
timeout:2000,
});
return false;
})
}
函数采用function post_data()写法
$.ajax添加return false;