我如何使用ajax连接到sql并使用ajax从数据库中获取值到jsp文件
js文件:
$(document).ready(function() {
$("#btnList").click(function() {
window.location.href = "http://localhost:8087/salutationlist";
});
$("#btnSave").click(function() {
var code=$("#txtCode").val();
var name=$("#txtName").val();
var genderID=$("#txtGender").val();
var details = {
"code" : "code",
"name" : "name",
"genderID" :"genderID",
"activeYN":true
};
$.ajax({
url : "http://localhost:8088/save",
type : "POST",
data : JSON.stringify(details),
dataType : "json",
contentType :"application/json; charset=utf-8",
success: function(response){
},
'error' : function(request,error)
{
alert("Request: "+JSON.stringify(request));
}
});
});
});