【发布时间】:2016-11-08 10:59:59
【问题描述】:
我无法使用 jquery ajax 使用 Web 服务,但可以使用 C# 语言。 这是我的 jquery Ajax 代码`
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="jquery-3.0.0.js"></script>
<script>
$(document).ready(function(){
var url = "http://192.xxxx.xx.xx:10000/service1.asmx/GetJsonData";
$.ajax({
type: "GET",
url: url,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
alert("hii");
alert(data.d)
},
error: function (xmlHttpRequest, textStatus, errorThrown) {
alert("error");
}
});
})
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
The above code is not working but when i am trying the same using C# language it is working fine.
错误是:网络错误:IE浏览器拒绝访问。
Google Chrome 中的错误如下所示。 XMLHttpRequest 无法加载 http://192.xxxx.xx.xx:10000/service1.asmx/GetJsonData.No 请求的资源上存在“Access-Control-Allow-Origin”标头。 Origin 'http://localhost:49951' 因此不允许访问。
`
【问题讨论】:
标签: c# jquery ajax web-services