I have an AJAX request and in the success handler, to be able to grab the data anywhere I pass it to a function, called dataHandler
. From there I handle what I need and end up with an array of items.
function dataHandler() {
var myArray = ["21/06/2016"];
}
I'm trying to pass what i've got in the dataHandler()
function to another function that is self invoking but if I named the function like $(function myName(){}
then in my first function did myName(myArray);
I still can't access the data.
$(function() {
console.log(myArray);
})
How can I pass a variable from a normal function to a self invoking function?