<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="application/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="application/javascript" type="text/javascript">
$(document).ready(function(){
crosRequest();
});
function crosRequest(){
var json = {
"username" : "test",
"password" : "test"
};
$.ajax({
url: 'http://122.51.248.77:8520/user/addUser',
type: 'post',
contentType: 'application/json;charset=utf-8',
dataType: 'json',
data: JSON.stringify(json),
success: function(res){
console.log(res);
}
});
}
</script>
</head>
<body>
<button type="button" class="btn btn-link" onclick="crosRequest()">请求跨域资源</button>
</body>
</html>