-1

im trying to change one var to get and stuck

here is what I did:

var choices = [['Australia', 'au'], ['Austria', 'at'], ['Brasil', 'br']];

so this is working, and I want to change it on

$.getJSON('/modules/profile/readCountry.php',function(data){
    arrays = data;
});
var choices = arrays;

but is not working

the php file is:

foreach($countryies as $countr => $countrv) {
    $json[] = array($countrv,$countr);
}
header("Content-type:application/json"); 
$out = array_values($json);
echo json_encode($out);

and output is:

[['Australia', 'au'], ['Austria', 'at'], ['Brasil', 'br']]

how to fine out what is missing or is not working ?

okapo
  • 3
  • 1
  • 4

1 Answers1

0

$.getJSON is async call

    var choices = [];
    $.getJSON('/modules/profile/readCountry.php',function(data){
        choices = data;
        // do something with array
    });
Interreto
  • 122
  • 1
  • 3