我无法从本地主机api获得响应。 您尝试过的另一种方法==以及添加标头Access-Control-Allow-Headers ='*'
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function (){
Approve()
});
function Approve(){
alert("hello")
$.ajax({
//url: "http://127.0.0.1:5000/api?Id=3?callback=?",
url:"https://cors-anywhere.herokuapp.com/http://127.0.0.1:5000/api/all",
//jsonp: "callback",
data:{},
success: function(response) {
console.log(response); // server response
}
});
}
</script>
</head>
<body>
<div class="container">
<input type="button" value="Approve" onclick="javascript:Approve()" />
</body>
</html>```