JSON format via AJAX
<p>i getting the json response via ajax so when i doing alert of the json response array length is showing correctly the code is </p>

<pre><code>try {
    xmlHttp.open("GET", "ajaxmodel_new.php?model_id="+model_id,true);
    xmlHttp.onreadystatechange = function() {
        if (xmlHttp.readyState == 4 &amp;&amp; xmlHttp.status==200){
        model_details_json =  JSON.parse(xmlHttp.responseText)
        alert(model_details_json.communication.length)
        }
    }
</code></pre>

<p>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 </p>

<pre><code>function options(){

    document.getElementById('selected_opt').style.display = '';

    if(model_details_json.communication.length != 0 ){
}
}
</code></pre>

<p>it is showing error as model_details_json.communication is undefined , here model_details_json is an global varaible</p>
