I'm trying to return a global variable and set an object in an array.
Could anyone explain what I am doing wrong to retrieve the global variable outPutArray
? It become undefined when I try to return it.
var outPutArray = {};
var goAjax = function(data, filePath) {
data = $(this).serialize() + "&" + $.param(data);
$.ajax({
type: "POST",
dataType: "json",
url: filePath, //Relative or absolute path to response.php file
data: data,
success: function(data) {
for (x in data) {
outPutArray[x] = data[x];
}
//logs the the wanted value
console.log('inside ' + outPutArray['json']);
}
});
};
goAjax.prototype.getValue = function() {
console.log('outside ' + outPutArray['json']);
//logs undefined ??
};
First I would like to thank every one who tried to help me .The answer is to use a parameter that would work as an interface in java to fire a function inside another function or a method to be fired inside other method .
An example
The response.php script