Simple jQuery-Tests

Array
(
    [0] => stdClass Object
        (
            [id] => 1
            [name] => Germany
            [cities] => Array
                (
                    [0] => stdClass Object
                        (
                            [id] => 1
                            [name] => Berlin
                        )

                    [1] => stdClass Object
                        (
                            [id] => 2
                            [name] => Karlsruhe
                        )

                    [2] => stdClass Object
                        (
                            [id] => 3
                            [name] => Tuttlingen
                        )

                    [3] => stdClass Object
                        (
                            [id] => 4
                            [name] => Speyer
                        )

                )

        )

    [1] => stdClass Object
        (
            [id] => 2
            [name] => France
            [cities] => Array
                (
                    [0] => stdClass Object
                        (
                            [id] => 5
                            [name] => Paris
                        )

                    [1] => stdClass Object
                        (
                            [id] => 6
                            [name] => Lyon
                        )

                    [2] => stdClass Object
                        (
                            [id] => 7
                            [name] => Toulouse
                        )

                    [3] => stdClass Object
                        (
                            [id] => 8
                            [name] => Bordeaux
                        )

                )

        )

    [2] => stdClass Object
        (
            [id] => 3
            [name] => Lithuania
            [cities] => Array
                (
                    [0] => stdClass Object
                        (
                            [id] => 9
                            [name] => Vilnius
                        )

                    [1] => stdClass Object
                        (
                            [id] => 10
                            [name] => Kaunas
                        )

                    [2] => stdClass Object
                        (
                            [id] => 11
                            [name] => Klaipėda
                        )

                    [3] => stdClass Object
                        (
                            [id] => 12
                            [name] => Šiauliai
                        )

                )

        )

    [3] => stdClass Object
        (
            [id] => 4
            [name] => Italy
            [cities] => Array
                (
                    [0] => stdClass Object
                        (
                            [id] => 13
                            [name] => Rom
                        )

                    [1] => stdClass Object
                        (
                            [id] => 14
                            [name] => Milano
                        )

                )

        )

)

You can send a request to the PHP-Script "api.php" using POST-Parameters.
Request-Parameters (POST) Description Response
Name Value
method getCountries Returns a JSON-Array with all countries.
[
  {
    "id": 1,
    "name": "Germany"
  },
  {
    "id": 2,
    "name": "France"
  }
]
                        
method getCities Returns a JSON-Array with all cities of the requested country.
[
  {
    "id": 9,
    "name": "Vilnius"
  },
  {
    "id": 10,
    "name": "Kaunas"
  }
]
                        
country The ID of the requested country.
Task 1
Please use the data given in the PHP-Variable $aCountries to fill the two select-fields in the Form with the ID formStatic.
After that, please write a small JavaScript-Code using jQuery that implements the following conditions:
Task 2
Please write a JavaScript using jQuery, that loads the countries and cities from the api.php and fills the two dropdowns in the form with the ID formAsync.
The script should implement the following conditions:
Test 1 (Static)
Test 2 (Build Async)