$.getJson> $.each returns undefined

Posted by Der Sep on Stack Overflow See other posts from Stack Overflow or by Der Sep
Published on 2010-03-17T20:02:51Z Indexed on 2010/03/17 20:11 UTC
Read the original article Hit count: 580

Filed under:
function getData(d){
Back = new Object();

$.getJSON('../do.php?',
   function(response){    
    if(response.type == 'success'){ 
    Back = { "type" : "success", "content" : "" };
    $.each(response.data, function(data){   
       Back.content +='<div class="article"><h5>'+data.title+'</h5>'
       Back.content +='<div class="article-content">'+data.content+'</div></div>';
      });

    }
    else{
     Back = {"type" : "error" };
    }

    return Back;
  });
}

console.log(getData()); 

is returning undefined! why?

© Stack Overflow or respective owner

Related posts about jQuery