[jQuery] returning an object array to a JS function - doesnt work
Hi,
I'm mixing regular javascript with Jquery and for some reason I cannot
pass a return value back - any idea why?
output = loadXMLarray('echo.php','datatable1') );
alert (output); // does not work
function loadXMLarray(scripturl,variable){
$.get(scripturl,{xml:variable}, function(data){ // loading my XML
objectArray = new Array(); // setting up my array to hold objects
with
$(data).find('row').each(function(i){ // iterating through my XML
source
rowObj = new Object(); // adding attributes to my 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); // populating my array
});
alert(objectArray); // this works
return objectArray; // does not work
});
return objectArray; // tried it here as well but that returns nothing
}