Search code examples
javascriptjqueryarrayswindowraphael

Window object appearing in array


When I run the code below, jQuery, repeatedly, puts a Window object in my array (and I'm sure the JSON doesn't include any references to the Window object). Is there any way to run this and keep the Window object out of my array?

Thanks

$.getJSON("../php/return_network_data.php",
function(fetch_data){
    $.each(fetch_data, function(){
    var index = this.id;
    node_array[index] = paper.circle(this.xpos_init, this.ypos_init, 10).attr({"fill" : "#ff0000"})

    $.each(node_array, function(){
            console.log(this);
      });
  });
}
);   

Solution

  • This should work..have to add index,value in each function

    $.getJSON("../php/return_network_data.php",
    function(fetch_data){
        $.each(fetch_data, function(index,value){
        var index2 = value.id;
        node_array[index] = paper.circle(this.xpos_init, this.ypos_init, 10).attr({"fill" : "#ff0000"})
    
        $.each(node_array, function(index,value){
                console.log(value);
          });
      });
    }
    );