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

Popular posts from this blog

PHP while loop dynamic rowspan -

timer - Java TimerTask cancel -

android - How to read a column value in parse.com without accessing an object or a pointer -