$(function(){
$(‘#testMySQL_Select‘).click(function(){
console.log($("#testMySQL_account").val());
console.log($("#testMySQL_password").val());
var data = {
account:$("#testMySQL_account").val(),
password:$("#testMySQL_password").val()
};
var json_data = JSON.stringify(data);
console.log(json_data);
$.({
type: "post",
//async:false,//同步:意思是当有返回值以后才会进行后面的js程序。
url: "/QC_Conductor/user/testMySQL",
dataType: "json",
contentType :‘application/json;charset=utf-8‘,
data: json_data,
success: function(result){
var json_result = JSON.stringify(result);
console.log("data:"+json_result);
$("#testMySQL_return").val(result.name);
// $(window).attr("location","login.html");
},
error: function (xhr, textStatus, errorThrown) {
/*错误信息处理*/
console.log("进入error---");
console.log("状态码:"+xhr.status);
console.log("状态:"+xhr.readyState);//当前状态,0-未初始化,1-正在载入,2-已经载入,3-数据进行交互,4-完成。
console.log("错误信息:"+xhr.statusText );
console.log("返回响应信息:"+xhr.responseText );//这里是详细的信息
console.log("请求状态:"+textStatus);
console.log(errorThrown);
console.log("请求失败");
}
})
})
});
原文:https://www.cnblogs.com/kldywx/p/12710437.html