Hi Guys,
I have some code which i try to get a string eg:
subcategoryhtml = getsubcategories(submitcategory);
Which will execute the code below that should get a list of categories
from an xml file. However this code doesnt work until the next time
around or other click. I have a feeling some part of the code executes
before the request is done. Can anyone help me figure what I am doing
wrong.
function getsubcategories(submitcategory){
var subcategorystring="";
var categoryarray=[];
var categoryhtmlcode="";
var request = GXmlHttp.create();
request.open("GET", "http://www.ie.com/files/" + "english/" +
"category.xml", true);
request.onreadystatechange = function()
{
if (request.readyState==4)
{ //Removed for IE documentElement error.
//var xmlDoc = request.responseXML;
var xmlDoc = GXml.parse(request.responseText);
// obtain the array of markers and loop through it
var markers = xmlDoc.documentElement.getElementsByTagName
("marker");
for (var i = 0; i < markers.length; i++)
{ // obtain the attribues of each marker
subcategorystring = markers[i].getAttribute
("subcategory");
categoryarray[i]=subcategorystring;
categoryhtmlcode += '<option value="' + categoryarray[i] +
'">' + categoryarray[i] + '</option>';
}
subcategorytexthtml = '<select style="font-family:
Helvetica,Verdana, Arial, sans-serif;font-size:10px;text-align:left"
name="subcategory" id="subcategory">'+ categoryhtmlcode +'</select>';
alert(subcategorytexthtml);
}
}
request.send(null);
return subcategorytexthtml; //This is global variable
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps 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-Maps-API?hl=en
-~----------~----~----~----~------~----~------~--~---