【发布时间】:2020-02-18 02:43:30
【问题描述】:
.ajax({
cache: false,
url: '/Dashboard/ListofNames',
data: {
charSearch: txtboxvalue
},
success: function (res){
var obj = JSON.parse(res); //this object contains 1 index which is 0.
var parseObj = JSON.parse(obj[0].JsonResult) // This line is working i successfully gets the data from index 0
var parseObj2 = JSON.parse(obj[1].JsonResult) //This is not working because index 1 is not existing, what i want is instead of getting an undefined exception, i want to set the index 1 into an empty string or whatever solution that i wont get any undefined exception.
}
});
任何建议都会对我有帮助,谢谢。
【问题讨论】:
-
请澄清您的具体问题或添加其他详细信息以准确突出您的需要。正如目前所写的那样,很难准确地说出你在问什么。请参阅如何提问页面以帮助澄清此问题:stackoverflow.com/help/how-to-ask
标签: javascript json ajax object