I have the following source code:
var labeled_pic = new Array();
var testing;
function get_label_pic(){
$.ajax({
url: "localhost/advanceSearch/index/getlabelpic",
type: "POST",
dataType: "json",
success: function(data) {
$.each(data, function(key, data){
labeled_pic[key] = data;
});
testing = "testing";
}
});
};
get_label_pic();
console.log(labeled_pic);
And then I call those function using get_label_pic();, after that I want to access labeled_pic array using labeled_pic[3] but it's return undefined. I use firebug, and I try to write this console.log(labeled_pic), and it's return:
How can I access the labeled_pic variable,.?
$("#result").append("<img src='" + labeled_pic[3] +"' />");