jquery - Create array from AJAX request data and use in another function -
$('#get_test').click(function(){ $.post('ajax-request.php', { act: 'start_test' }, function(data) { var jstring = $.parsejson(data);
so in jstring
have data associated english_word
, russian_word
. how save russian_word
data in array , use in different function?
if understand correctly, either pass data directly other function within success handler function so
$('#get_test').click(function(){ $.post('ajax-request.php', { act: 'start_test' }, function(data) { var jstring = $.parsejson(data); myfunction(jstring.russian);
or persist data scoped variable :
var russian=[]; $('#get_test').click(function(){ $.post('ajax-request.php', { act: 'start_test' }, function(data) { var jstring = $.parsejson(data); russian=jstring.russian;
and pick value in function :
function myfunc(){ console.log(russian); }
Comments
Post a Comment