Error in accessing global variable in jquery
<p>I've got the following js. The issue is that, I am unable to access the variable jasonServiceUrlObject in the getMajorGroups function. I've declared the variable globally but firebug throws a not defined error when the alert runs! </p>

<pre><code>var jsonServiceUrlObject = null;

function loadServiceXml(){
    $.get("/xml/ServiceUrls.xml", function(xml){
        jsonServiceUrlObject = $.xml2json(xml);

    });
}

function getMajorGroups(){
  var element = $(".item-group-button").first();

  var serviceUrl = getServiceURL("getAllMajorGroups")
  alert(jsonServiceUrlObject.service[1].service_key);
  $.get(serviceUrl , function(data){
    if(data.majorGroups.length != 0){
      $('.panel_list').empty();
      element.empty();
    }
    for(var i = 0; i &lt; data.majorGroups.length; i++){
      var clone = element.clone();
      clone.append("&lt;h3&gt;" + data.majorGroups[i].description + "&lt;/h3&gt;");
      clone.attr("id", data.majorGroups[i].majorGroupId);
      $('.panel_list').append(clone);
    }
  });
}
</code></pre>
