I have a simple ajax function
function get_country(request_term) {
var country_list = '';
$.ajax({
url : "activity/get_country",
type : "POST",
cache : false,
data : {
request_term : request_term
},
success : function(data) {
if(data != '') {
country_list = $.parseJSON(data);
alert(country_list); ----> Got value here
}
}
});
alert(country_list); ----> Not getting value here
return country_list;
}
the problem is, i'm getting the data in the success function, but unable to return it from the main function.