Below is the code that I am working on. As you can see, I created a variable called 'my_string', as a default, I want to call the get_result_data() function and store any return data on the variable 'my_string'. Then, once the user click the $('#button')
, I want to display the stored data. But the problem is, I am always getting an unidentified error.
function get_result_data(){
$.ajax({
type: 'POST',
url: 'ajax/get_result.php'
}).done(function(data){
return data;
});
}
var my_string = get_result_data();
$('#button').click(function(){
alert(my_string);
});