How can I use results of ajax request outside the ajax function?
I send results to other function, it should normally work.
This is the code I used.
function ajaxcall_array(value) {
var tmpajaxdata = new Array();
for (var i = 0; i < value.length; ++i){
tmpvar=(value[i]) ;
tmpajaxdata.push(tmpvar) ;
return tmpajaxdata ;
}
return tmpajaxdata ;
alert(tmpajaxdata);
console.debug(tmpajaxdata);
}
function ajaxcall(){
$.ajax({
url: 'ajax.php',
data: "name",
type:'GET',
async:false,
dataType: 'json', //data format
success: function(results) //on recieve of reply
{
ajaxdata = ajaxcall_array(results) ;
return ajaxdata ;
}
});
return ajaxdata ;
alert(ajaxdata);
}
ajaxcall();
Thanks