veysel Posted February 5, 2020 Share Posted February 5, 2020 (edited) Hello, var j; for (j= 1; j <=limit; j=j+1) { var value1 = str1.concat(obj.sky[0].satellites[j].PRN); } i do this and it is working in web page but if i do inspect element it says : Uncaught TypeError: Cannot read property 'PRN' of undefined at Object.success ((index):444) at i (VM16347 jquery-3.2.1.min.js:2) at Object.fireWith [as resolveWith] (VM16347 jquery-3.2.1.min.js:2) at A (VM16347 jquery-3.2.1.min.js:4) at XMLHttpRequest.<anonymous> (VM16347 jquery-3.2.1.min.js:4) i am not good at js can anyone tell me what is my fault ? Edited February 5, 2020 by veysel Quote Link to comment https://forums.phpfreaks.com/topic/309983-uncaught-typeerror/ Share on other sites More sharing options...
Barand Posted February 5, 2020 Share Posted February 5, 2020 I'd guess that satellite[j] does not exist for the current value of j. You need more satellites It's better to use foreach() when iterating through arrays instead of for() (which expects a satellite to always be present for every value of j) 1 Quote Link to comment https://forums.phpfreaks.com/topic/309983-uncaught-typeerror/#findComment-1574014 Share on other sites More sharing options...
veysel Posted February 5, 2020 Author Share Posted February 5, 2020 (edited) Hello First of all thank you so much before i ask question, i have this line: var limit=obj.sky[0].satellites.length; if (limit>10) { limit=10 } i want to monitoring max 10 values but it can be less. i solved it with your help. Here what i do for (j= 1; j <=limit-1; j=j+1) { var value1 = str1.concat(obj.sky[0].satellites[j].PRN); } Because obj.sky[0].satellites[j] does not contain obj.sky[0].satellites[0].PRN that's why as you said, satellite[j] does not exist for the current value of j Edited February 5, 2020 by veysel Quote Link to comment https://forums.phpfreaks.com/topic/309983-uncaught-typeerror/#findComment-1574015 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.