I believe I haven't fully grasped variable scope in jQuery and need some help to understand why the variable "final_shasign" comes out fine inside the AJAX but is undefined outside the AJAX despite it being declared outside of the AJAX.
var final_shasign; // initial declaration outside of ajax block below
$.ajax({
type: "POST",
url: "sha.php",
data: "amount="+amount+"&cn="+cn+"¤cy="+currency+"&language="+language+"&orderid="+orderid+"&pspid="+pspid,
success: function(response_data, final_shasign){
var parsed_data = $.parseJSON(response_data);
final_shasign = parsed_data.shasign;
console.log ("inside nested ajax: " + final_shasign); //comes out fine
}
});
console.log ("outside of nested ajax: " + final_shasign); //comes out as undefined!