当前位置: 动力学知识库 > 问答 > 编程问答 >

javascript - Microsoft JScript runtime error: Unable to get value of the property 'length': object is null or undefined

问题描述:

I am getting this error when data is null. I checked for null but still getting same error :

Unable to get value of the property 'length'.

Below is my code.

success: function Success(data) {

if (data) {

alert(data.post);

for (var i = 0; i < data.d[i].length; i++) {

}

$("[Id*=lblSuperVisorName]").html(data.d[i].SuperVisorName);

$("[Id*=lblmobileNo]").html(data.d[i].MobileNo);

}

else {

alert(data.post);

}

},

Checking to see if AJAX response is empty and other problems?

网友答案:
Calculate the lenght of passed data by dada.d.lenght  if lenth is greater than zero then assign value to lable.

success: function Success(data) {
                     var len = data.d.length;
                    if (len != 0) {

                        for (var i = 0; i < data.d[i].length; i++) {
                        }                 
                        $("[Id*=lblmobileNo]").html(data.d[i].MobileNo);
                        $("[Id*=lbluid_nmbr]").html(data.d[i].uid_nmbr);
                     }  
分享给朋友:
您可能感兴趣的文章:
随机阅读: