I'm currently working with google maps and I want to save some locations in a database and retrieve them through an ajax call, after which I make JavaScript objects from the locations.
As for the code I am not really sure why this is not working, can someone clear this up for me?
Chrome Console: Uncaught TypeError: this.processData is not a function
var Locations = {
count: 0,
location: [],
processData: function (data) {
console.log(data);
},
getData: function () {
'use strict';
jQuery.ajax({
type: 'get',
url: '../../php/functions/getLocations.function.php',
dataType: 'json',
success: function (data) {
this.processData(data);
}
});
}
};
function getLocation() {
return $.ajax({
type: 'get',
url: '../../php/functions/getLocations.function.php',
dataType: 'json'
});
}
getLocation().done(function(result) {
console.log(result);
return result;
});