Ajax请求后端数据解析
ajax请求后端数据
发送请求get发...
ajax请求后端数据
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script><script type="text/javascript">
function sendajaxpost(){
let json = {
username: "lindont",
password: "123456"
}
$.ajax({
type: "post",
url: "https://localhost:8787/test/params",
contenttype: "application/json; charset=utf-8",
data: json.stringify(json), /*传给后端的数据格式json*/
datatype: "json", /*后端返回的数据格式json*/
success: function(data){
console.log(data);
},
error: function (message) {
}
});
}
function sendajaxget() {
$.ajax({
type: "get",
url: "https://localhost:8787/test",
success: function(data){
console.log(data);
},
error: function (message) {
}
});
}
</script>