Javascript scope variable..?

500                 <script type="text/javascript">
    501                     google.load("visualization", "1",
{packages:["table"]});
    502                     google.setOnLoadCallback(drawTable);
    503                     function drawTable() {
    504                         var data = new
google.visualization.DataTable();
    505                         data.addColumn('string', 'Id');
    506                         data.addColumn('string', 'PI');
    507                         data.addColumn('string', 'Cruise
Info');
    508                         data.addColumn('string', 'Date and
Time');
    509                         data.addColumn('string', 'Latitude');
    510                         data.addColumn('string', 'Longitude');
    511                         data.addColumn('string', 'Depth');
    512                         data.addColumn('string', 'Name');
    513                         data.addColumn('string', 'Value');
    514                         data.addRows(1);
    515
    516                         GDownloadUrl("../output/search/
results.xml", function(data) {
    517                             xml = GXml.parse(data);
    518                             dataId =
xml.documentElement.getElementsByTagName("data_id");
    519                 //          alert(dataId[0].childNodes
[0].nodeValue);
    520                             id = dataId[0].childNodes
[0].nodeValue;
    521                           //  alert(id);
    522                          //   for (var i = 0; i <
dataId.length; i++) {
    523                         //      var id = new Integer(parseInt
(dataId[i]));
    524                         //      alert(id);
    525                          //   }
    526                            data.setCell(0, 0,
"id");
    527                         });
    528                         data.setCell(0, 0, "id");
    529                         var table = new
google.visualization.Table(document.getElementById('table_div'));
    530                         table.draw(data, {showRowNumber:
true});
    531                     }
    532
    533                 </script>

Line 526 does not work.

Line 528 does.

This leads me to believe I cannot run setCell inside.. the called to
GDownloadUrl. However, this brings up the issue of variable scoping.
For example, I am not able to do "alert(id)" outside of the call to
GDownloadUrl either. Even if I declare id as a global var.



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/google-visualization-api?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to