Currently, I am able to pass parameters from one JavaScript file to another using the jQuery method "$.getScript". For example, in the "secondJavaScript.js" file, I use a $.getScript call to invoke the function callMemoPage() from "firstJavaScript.js", passing the parameters "pageName" and "acctNum". The challenge is how to retrieve the value of the function "callMemoPage" in the "secondJavaScript.js" file and store it in the variable "Memo" located in "firstJavaScript.js".
$.getScript('firstJavaScript.js', function(){
getMemo();
function getMemo(){
var pageName = "Memo Page";
var acctNum = "123";
// callMemoPage function is defined in "firstJavaScript.js"
callMemoPage(pageName, acctNum);
console.log(Memo);
}
});
// firstJavaSctipt.js file
function callMemoPage(pageName, acctNum){
var Memo;
if(pageName == 'Memo Page' && acctNum == '123'){
function(memoField){
var memoField = window.open("https://www.example.com");
// question remains on how to pass the value of Memo into secondJavaScript.js file
Memo = $(memoField).find('input[name="MEMO"]').val();
}
}
}