Having this function :
var mapdata={};
console.log( mapdata[0].phones );
function fetchSteeringRecs()
{
$.ajax({
url : "./php/ajxcontrol.php",
type : "POST",
data : { dorecs:1 },
dataType : "json",
async : false,
//success : successHandler,
success : function(data) {
mapdata = data;
// console.log( data[0].phones );
}
});
}
/*
function successHandler(data, status ) {
console.log( data[0].phones );
}
*/
i would like to use the returned data after assigning it to 'mapdata' object - but i keep getting error in console:
Uncaught TypeError: Cannot read property 'phones' of undefined
As can be seen i have tried accessing the data from within a callback successHandler function and it works ok - also i can access the returned data directly in the ajax success func (both commented out) - but i really need it in the 'global object 'mapdata'
Is this possible or is my technique here wrong?