I know little about variable scope, have been reading up on OOP, but I
don't understand why this would not work.
I tried inserting "return objectArray" in various places to no
avail...

$('#button1').click(function(b){
    $().loadXML2array('url','var');
    alert(objectArray);               // does not work
});


jQuery.fn.extend({
    loadXML2array: function(url,variable) {
        return this.each(function() {
            $.get(url,{xml:variable}, function(data){
                 objectArray = new Array();
                 $(data).find('row').each(function(i){
                     rowObj = new Object();
                     rowObj.col1 = $(this).children('col_1').text();
                     rowObj.col2 = $(this).children('col_2').text();
                     rowObj.col3 = $(this).children('col_3').text();
                     objectArray.push(rowObj);
                });
            });
        });
    }
});

Reply via email to