gpt4 book ai didi

c# - 识别 ajax-jquery 中 web 方法获取的返回值

转载 作者:行者123 更新时间:2023-11-30 21:06:02 24 4
gpt4 key购买 nike

我写了一个有字符串返回值的 web 方法。这个返回值从存储过程中获取。但是当条件不成立时返回未定义的值。我写了下面的代码但它没有工作

   $.ajax(
{
type: "POST",
url: "WebForm1.aspx/confirm",
data: JSON.stringify({
username: username,
password: password, email: email,codemeli: codemeli}),
contentType: "application/json; charset=utf-8",
dataType: "json",

async: true,
cache: false,
success: function (ret) {

if (ret != "") {
$('#result').text(ret.d + " : " + "it is reserved "+ret.lenght); }
else { $('#result').text("the operation is successful"); }
},
error: function (x, e) {
$('#result').text(x.responseText);
}
}
);

最佳答案

ret.lenght 在您的 success 回调中应该是 ret.d.length

关于c# - 识别 ajax-jquery 中 web 方法获取的返回值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11408141/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com