【发布时间】:2017-05-27 04:24:17
【问题描述】:
我将 javascript ajax 连接到 webservice asmx 但无法正常工作。 我测试从 aspx 连接到 web 服务它工作。
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script src="jquery-3.1.1.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" language="javascript">
$(function () {
$('#btnCallService').click(function () {
$.ajax({
type: 'POST',
url: 'http://xxxxxxxx/ws/webservice.asmx/HelloWorld',
dataType: 'json',
contentType: 'application/json; charset=utf-8',
success: function (response) {
$('#lblData').html(JSON.stringify(response));
},
error: function (error) {
console.log(error);
}
});
});
});
</script>
</head>
<body>
<input type="button" id="btnCallService" value="GetEmployeeDetail" />
<label id="lblData"></label>
</body>
</html>
点击按钮后
【问题讨论】:
标签: javascript jquery asp.net ajax web-services