i getting the json response via ajax so when i doing alert of the json response array length is showing correctly the code is
try {
xmlHttp.open("GET", "ajaxmodel_new.php?model_id="+model_id,true);
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4 && xmlHttp.status==200){
model_details_json = JSON.parse(xmlHttp.responseText)
alert(model_details_json.communication.length)
}
}
so the alert is giving as 4 .... the same thing i.e so i need to use model_details_json.communication.length in other function say
function options(){
document.getElementById('selected_opt').style.display = '';
if(model_details_json.communication.length != 0 ){
}
}
it is showing error as model_details_json.communication is undefined , here model_details_json is an global varaible
options()within the callback function of ajax.