https://www.jianshu.com/p/1ab2c47a9c0b
https://www.cnblogs.com/chiangchou/p/jsonp.html
jsonp方式 datatype指定
<html>
<head>
<title>跨域测试</title>
<script src="js/jquery-1.7.2.js"></script>
<script>
$(document).ready(function () {
$("#btn").click(function () {
$.ajax({
url: "http://localhost:9090/student",
type: "GET",
dataType: "jsonp", //指定服务器返回的数据类型
success: function (data) {
var result = JSON.stringify(data); //json对象转成字符串
$("#text").val(result);
}
});
});
});
</script>
</head>
<body>
<input id="btn" type="button" value="跨域获取数据" />
<textarea id="text" style="width: 400px; height: 100px;"></textarea>
</body>
</html>
cores方式
https://blog.csdn.net/lishanleilixin/article/details/79931298
<script> var url = ‘http://www.lishanlei.cn/CorsTest/CorsTest.php‘; var xhr = new XMLHttpRequest(); xhr.open(‘get‘, url, true); // xhr.setRequestHeader(‘X-Custom-Header‘, ‘value‘); xhr.send(); </script>
原文:https://www.cnblogs.com/infaaf/p/9583549.html