I have 2 method. second one calls the first one. When I put an alert function into the first one I can see the return value. But second function see the value as undefined. I couldnt understand why 2. one can't handle the value?
function getTweetReply(id_str) {
$.getJSON("get_tweet_reply.php", {id_str: id_str}, function(json) {
tweet_relpy = '<blockquote>'+json.results[0].text+'</blockquote>';
alert(tweet_relpy); // --> I can see the result
return tweet_relpy;
});
}
$(document).on("click", ".tweet",function(){
var id_str = $(this).attr("id");
$.getJSON("get_tweet_details.php", {id_str: id_str}, function(json) {
tweet = '<img src="'+json.results[0].profile_image_url+'"><br>\
' + json.results[0].from_user + '<br>\
' + json.results[0].from_user_name + '<br>\
' + getTweetReply(json.results[0].id_str) + '</b><br>'; // --> undefined
$("#float").html('<div id="replybox">'+ tweet +'</div>');
});
});