I am a noob when it comes to using loadURL function. I am trying to make a
request to my WFS server just to return a list of attributes about a
particular feature. This seems to be working using the below code however I
am trying to use the variable neighbourhood_list as a global variable so I
can use this list of attributes throughout my application. I see from
OpenLayers.loadURL that it is using the wfs_request function i have set as
its OnComplete method. Is it possible for me either to set the response from
loadURL to a variable or is there a different way to do this because
obviously with the below code my variable neighbourhood_list is only set to
the right attributes within the wfs_request method otherwise it is null...or
is there a better way I should be doing this to load attributes into an
array from my WFS? I really appreciate any assistance thanks.
function init()
{
var neighbourhood_list;
var wfs_url_hoods =
"http://localhost/RedWFS/request.aspx?REQUEST=getFeature&SERVICE=WFS&TYPENAME=Neighbourhoods&version=1.1.0"
OpenLayers.loadURL(wfs_url_hoods,'',null,wfs_request);
function wfs_request(response)
{
var g = new OpenLayers.Format.GML;
features = g.read(response.responseText);
for(var feat in features) {
var attributes;
for (var j in features[feat].attributes) {
if (j == "NEIGHBOURHOOD_NAME")
{
attributes += features[feat].attributes[j]+",";
}
else
{
}
}
}
neighbourhood_list = attributes;
} // end of wfs_request function
alert(neighbourhood_list); // here it is undefined
--
View this message in context:
http://osgeo-org.1803224.n2.nabble.com/Question-using-OpenLayers-loadURL-by-setting-response-to-a-variable-tp5636485p5636485.html
Sent from the OpenLayers Users mailing list archive at Nabble.com.
_______________________________________________
Users mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/openlayers-users