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

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -