我处于能够弄清楚我错在哪里的情况。

我正在使用jquery调用Web服务。它正常工作,因为它调用webmethod完成操作。但它调用函数服务失败的错误条款而不是成功的$ .ajax调用

如果服务是successfule,它应该提醒我'hi'。但它正在调用ServiceFailed函数,但是当我输入并使用$ .ajax调用传递给服务时,数据库值会完美更新

我的j查询代码是休闲的

function 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方法是休闲的

[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

Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐