我编写了一个具有字符串返回值的 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);
}
}
);