var code;
var Name;
$(window).on("load", function () {
$.ajax({
url: "URL_THAT_RETURNS_JSON"
}).done(function (json) {
code = json.country_code;
$(function () {
$.ajax({
url: "URL_THAT_RETURNS_JSON"
}).done(function (country) {
Name = country.code ?
})
})
})
})
I have a variable code and Name. The top function calls json and returns this value for example: { .... "country_code":"US" .... } so I put the country code value in the variable code. And the second ajax function will call a json file that looks like this: { "AF":"Afghanistan", "AL":"Albania", ... "ZW":"Zimbabwe" } I am trying to call the second variable with the country code I have, which is in side the code variable. Can I call the country code function and assign that into the Name variable?
For example => The first ajax function returned "US". So the code variable now has "US" inside. Now can I in anyway call the second ajax function so that the Name variable will have the value "United States"?
But in the json file, we have "US":"United States".