gpt4 book ai didi

javascript - JS错误:Cannot call method of null

转载 作者:行者123 更新时间:2023-11-30 23:47:02 26 4
gpt4 key购买 nike

我在 ASP.Net Web 项目的 js 文件中有以下方法。这个方法给出了错误无法调用 null 的“split”方法

 function loadUser_InfoCallBack(res)
{
var ret=res.value;
var senderGUID = ret.split(';')[0];
var senderText = ret.split(';')[1];

if(senderGUID.Length>0)
{
$('hiddenSender.value')=senderGUID;
$('hiddenText.value')=senderText;
}

}

任何人都可以提出此错误的原因吗?

<小时/>

其中 getOwnerInfo 方法的代码如下

[AjaxPro.AjaxMethod(AjaxPro.HttpSessionStateRequirement.ReadWrite)]
public string getOwnerInfo()
{
string strReturn = ";";

if (Session["User_GUID"] != null)
{
string strUserGUID = Session["User_GUID"].ToString();

string strIndGUID = "";
string strIndName = "";

//Initialize Connection String
cns = DAL360.Common.getConnection(HttpContext.Current.Session["Server"].ToString(), HttpContext.Current.Session["Database"].ToString());

DAL360.std_UserRepositoryArtifacts.std_UserRepository userRep = new DAL360.std_UserRepositoryArtifacts.std_UserRepository(cns);
std_User user = userRep.Getstd_UserByusr_GUID(new Guid(strUserGUID));


DAL360.std_IndividualRepositoryArtifacts.std_IndividualRepository indRep = new DAL360.std_IndividualRepositoryArtifacts.std_IndividualRepository(cns);
std_Individual ind = indRep.Getstd_IndividualByind_GUID(new Guid(user.usr_ind_GUID.ToString()));

if (ind != null)
{
strIndGUID = ind.ind_GUID.ToString();

strIndName = ind.ind_Prefix + " " + ind.ind_FirstName + " " + ind.ind_MiddleName + " " + ind.ind_LastName;

DAL360.std_IndividualAddressRepositoryArtifacts.std_IndividualAddressRepository iadRep = new DAL360.std_IndividualAddressRepositoryArtifacts.std_IndividualAddressRepository(cns);
List<std_IndividualAddress> iadList = iadRep.GetAllFromstd_IndividualAddressByIndGUID(ind.ind_GUID);

if (iadList != null && iadList.Count > 0)
{
std_IndividualAddress iad = iadList[0];
strIndName += " (" + iad.iad_City + ", " + iad.iad_State + ")";
}
}


strReturn = strIndGUID + ";" + strIndName;

}//end if statement


return strReturn;

}

该方法位于frmHome.aspx页面的代码隐藏页面中。当我尝试打开页面 frmHome.aspx

时出现错误

最佳答案

最可能的原因是没有任何元素资源。因此,采用 res.value 将返回 null,并且 split 需要一个字符串。

关于javascript - JS错误:Cannot call method of null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2711688/

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