using jquery $.ajax to retrieve data and push data into javascript array through the success functio
- by teamdane
Hello All,
I have a function that I'm trying to retrieve values using $.ajax and push the returned data into an array called output. Problem is the success function will not allow me to push the results into the array. see below for code.
var getValues = function(el)
{
var value = ($(el).val());
if(value == '' || $(el).attr('disabled'))
{
return [];
}
var string = 'value=' + value;
var output = [];
$.ajax({
type: "GET",
url: 'shocklookup_callback.php',
dataType: "string",
data: string,
success: function(data) {
}
});
//output.push({ text : value + 'test', value : value + 'test1'} );
return output;
};
Any ideas of what I can put in the success function to be able to push the data into the output array? Also I need to be able to return the output array to the original function getValues.
If this doesn't' make a whole lot of sense please let me know and I'll try to explain better.
Thanks,
Dane