$("#btnGet").bind("click", function () {
$.ajax({
url: "http://localhost:51571/api/Account/1",
type: "GET",
dataType:"jsonp",
success:function(result) {
alert(result[0].Id+","+result[0].Name+","+result[0].Email);
}
});
});
指定dataType为jsonp,而不是json即可!
解决“No 'Access-Control-Allow-Origin' header is present on the requested resource.”
最新推荐文章于 2024-05-10 21:47:27 发布