大家好, 请帮我以下。这是我的网络服务电话:
<WebMethod()> _
<WebInvoke(Method:="GET", BodyStyle:=WebMessageBodyStyle.Wrapped, ResponseFormat:=WebMessageFormat.Json, UriTemplate:="json")>
Public Function getData(data As String) As String
Return data
End Function
这是我从html
的网络服务电话 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript">
function serviceCall() {
$.ajax({
type: "POST",
url: 'http://localhost:49935/14MayWSWebsite/14MayWS.asmx/getModel',
data: "{'data':'This is static data from the JavaScript file'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
$("#divResult").html(msg.d);
},
error: function (e) {
$("#divResult").html("WebSerivce unreachable");
}
});
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div style="width: 100px; height: 30px; background-color:blue;" onclick="serviceCall();">Click me</div>
<div id="divResult" style="margin-top: 20px;"></div>
</form>
</body>
</html>
我收到错误:回来了 我想要做的是使用我已添加到此网站的Web服务引用来调用Web服务,但由于某种原因它不起作用。 我的Web服务表单中启用了脚本服务。