在ajax-jquery中识别web方法获取的返回值
问题描述:
我写了一个web方法,它有字符串返回value.this返回值获取表单存储过程。但是当条件未被建立时undefined值returned.i写下面的代码但它没有工作在ajax-jquery中识别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
应该是ret.d.length
在success
回调。
我这样做,但它返回undefined仍然 – quantum62 2012-07-10 07:18:51
在哪一行你会得到这个错误? – 2012-07-10 07:23:05