The console.log(oResponse);
of oResponse in the function mGetLookUpTableArray writes the information of the json_encoded object in the console log. There is data from the database in the oResponse object.
However console.log("aLookupTable: " + aLookupTable);
does not output anything. The message in the console log is aLookupTable: null
So aLookupTable which is passed in as an argument when I call mGetLookUpTableArray is not getting populated in mGetLookUpTableArray. Any ideas?
-
Javascript Making The Call of the Below Function
const sBasePath = ${window.location.protocol}//${window.location.host}${window.location.pathname.split(‘/’)[1] ? ‘/’ + window.location.pathname.split(‘/’)[1] + ‘/’ : ‘/’}`; // Outputs the base path, e.g., “https://example.com/subdirectory/”
const sURL = sBasePath + “db_includes/get_tb_Lookup.php”;
const aLookupTable = null; mGetLookUpTableArray(sURL, aLookupTable); console.log("aLookupTable: " + aLookupTable);
-
Javascript Function Being Called
function mGetLookUpTableArray(sURL, arrLookupTable) { $.ajax({ url: sURL, type: 'Post', dataType: 'json', success: function (oResponse) { console.log(oResponse); arrLookupTable = oResponse; }, error: function(oXHR, sStatus, oError) { console.error('Error:', oError); console.error('Status:', sStatus); console.error('Response:', oXHR.responseText); } }); }