我编写了一个简单的ASMX Web服务,其中包含从数据库中获取值的方法。我的服务代码是:
[WebMethod]
public string GetProductStock(string productId, string TerminalId, string CCPId)
{
ProductsDomain objProduct = new ProductsDomain();
objProduct.Product_Id = Convert.ToInt32(productId);
objProduct.TerminalId = Convert.ToInt32(TerminalId);
objProduct.CCPId = Convert.ToInt32(CCPId);
DataTable dt = objProduct.GetProductDetail();
if (dt.Rows.Count > 0)
{
return dt.Rows[0]["CurrentQty"].ToString();
}
else
{
return "0";
}
}
这是我的jquery函数:
function checkStock() {
var txt_PId = $("#content_body_content_lPId").text();
var txt_TerminalId = $("#content_body_content_lTerminalId").text();
var txt_CCPId = $("#content_body_content_lCCPId").text();
var msg = "{" + String.format("'productId':'{0}', 'TerminalId':'{1}','CCPId':'{2}'", txt_PId, txt_TerminalId, txt_CCPId) + "}"
// alert(msg);
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "CService.asmx/GetProductStock",
data: msg,
dataType: "json",
success: function (Result) {
alert();
Result = Result.d;
// data = Result
//alert(data)
},
error: function (Result) {
debugger;
alert("Error: " + Result.error.toString());
return false;
}
});
return false;
}
这个jquery方法返回错误,当我调试错误时,错误状态代码是500。 错误讯息:
错误:function(){if(h){var d = h.length;!function F(B){n.each(B,功能(B,C){风险 d = n.type(c)中;"功能" === d a.unique&安培;&安培; k.has(C)|| h.push(C):C&安培;&安培; c.length&安培;&安培;"串" == d&安培;&安培; F(℃)})}(参数),b E = h.length:C&安培;及(G = d,J(C)! )}返回 此}
任何人都可以建议我解决这个问题吗?
答案 0 :(得分:1)
driver_id team_id date contiguous_start_time contiguous_end_time hours
1 3 2017-11-29 10:00:00 13:00:00 3
1 3 2017-11-29 16:00:00 18:00:00 2
1 4 2017-11-30 17:00:00 18:00:00 1
1 4 2017-11-30 19:00:00 20:00:00 1
1 5 2017-11-30 18:00:00 20:00:00 2
的{{1}}上启用 [System.Web.Script.Services.ScriptService]
,才能通过class
的WebService
System.Web.Services.WebService
Jquery的
ajax