how to make visible this var (rec_count) out of ajax scope? I can't understand this about ajax scope. thanks!
function showImage(str){
$.ajax({
url: 'getimg.php',
type: "GET",
data: "q="+str,
dataType: 'json',
success: function(data){
rec_count = data.count;
console.log('inside: ' + rec_count)
}
});
}
$( document ).ready(function(){
$('body').click(function(){
showImage(4);
console.log('outside: ' + rec_count)
});
});