我的网络服务中有一个数据表,它是这样的
[WebMethod]
[ScriptMethod]
public DataTable mydbCon()
{
SqlConnection SqlCon = new SqlConnection(@"Data Source=myds;Initial Catalog=name;Persist Security Info=True;User ID=sa;Password=pwd");
SqlCon.Open();
SqlCommand SqlComm = new SqlCommand();
SqlComm.Connection = SqlCon;
SqlComm.CommandType = CommandType.Text;
SqlComm.CommandText = "select password from tbl_login where username='aby';";
DataTable EmployeeDt = new DataTable("tbl_login");
SqlDataAdapter SqlDa = new SqlDataAdapter(SqlComm);
SqlDa.Fill(EmployeeDt);
return EmployeeDt;
}
我在我的 HTML 页面中有一个 Ajax 调用,它是这样的,我没有得到一个显示错误消息的值
<script type="text/javascript">
function GetAge() {
jQuery.support.cors = true;
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
dataType: "json",
jsonp: 'jsonp_callback',
async: false,
url: "http://localhost:50113/Service1.asmx/mydbCon",
data: "{}",
success: function (msg) {
$('#divToBeWorkedOn').html(msg.d);
},
error: function (e) {
$('#divToBeWorkedOn').html("unavailable");
}
});
}
</script>