【发布时间】:2010-10-28 06:28:22
【问题描述】:
我处于无法弄清楚我错在哪里的情况。 我正在使用 jquery 调用 Web 服务。它工作正常,因为它调用 webmethod 完成了操作。但是它调用函数服务在错误子句上失败而不是在 $.ajax 调用中成功
如果服务成功,它应该提醒我“嗨”。但它正在调用 ServiceFailed 函数,但在我输入并使用 $.ajax 调用传递给服务时,数据库中的值会完美更新
我的 j 查询代码闲置
函数 ActionSendRequest() {
if (globArray.length > 0) {
alert(globArray.length);
document.getElementById('lblError').innerHTML = 'Please Wait.....';
for (var i = 0; i < globArray.length; i++) {
var Lot = globArray[i];
var Price = document.getElementById('prc' + globArray[i]).value;
var Quantity = document.getElementById('qty' + globArray[i]).value;
$.ajax({
type: "POST",
url: "../test.asmx/AddModReqSample",
data: "{Lot:'" + Lot + "',Price:'" + Price + "',Quantity:'" + Quantity + "'}",
contentType: "application/json; charset=UTF-8",
dataType: "xml",
processdata: true,
success: function (msg) {
ServiceSucceeded(msg);
},
error: ServiceFailed
});
}
}
}
function ServiceSucceeded(result) {
alert('hi');
if (result.d == "Error") {
}
else if (result.d == "Successfully") {
}
}
function ServiceFailed(result) {
document.getElementById('lblError').innerHTML = 'Service call failed: ' + result.status + '' + result.statusText;
}
而我的 WebService 方法是 fallows
[WebMethod(EnableSession = true)]
public string AddModReqSample(int Lot, decimal Price, decimal Quantity) {
if (SessionLog.UID != 0)
{
return objDataStore.ReqSample(Lot, SessionLog.UID, Quantity,Price);
}
else return "Please Login to the System";
} 我得到的最终信息是这样的 服务调用失败:200 OK
【问题讨论】:
标签: jquery