meclass.prototype.switch = function() {
var items = [];
$.getJSON('http://localhost/jsoner.php', function(data) {
$.each(data, function(key, val) {
items.push(val);
alert(items[0]); //this works
});
});
alert(items[0]); //this does not
}
I have been tinkering with this for awhile and not really getting it. I am having this problem in all of my jquery functions so it is something basic that I just haven't learnt- and haven't had luck finding answers on.