Jump to content

Recommended Posts

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 by veysel
Link to comment
https://forums.phpfreaks.com/topic/309983-uncaught-typeerror/
Share on other sites

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)

  • Thanks 1
Link to comment
https://forums.phpfreaks.com/topic/309983-uncaught-typeerror/#findComment-1574014
Share on other sites

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 by veysel
Link to comment
https://forums.phpfreaks.com/topic/309983-uncaught-typeerror/#findComment-1574015
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.