This is supposed to return a JSON object containing a list of picture filenames. The commented alert shows the correct data, but alert(getPicsInFolder("testfolder"));
shows "error"
.
function getPicsInFolder(folder) {
return_data = "error";
$.get("getpics.php?folder=" + folder, function (data) {
data = jQuery.parseJSON(data);
$.each(data, function (index, value) {
data[index] = "folders/" + folder + "/" + value;
});
//alert(data); // This alert shows the correct data, but that's hardly helpful
return_data = data;
});
return return_data;
}
What am I doing wrong?