<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Hi,<br><br>You must install a proxy script to retrieve information from remote domains via an XMLHttpRequest.<br><br><a href="http://trac.openlayers.org/wiki/FrequentlyAskedQuestions#ProxyHost">http://trac.openlayers.org/wiki/FrequentlyAskedQuestions#ProxyHost</a><br><br>Then you can use the class OpenLayers.Format.WMSCapabilities to parse the response like this:<br><br>var capabilitiesRequest = OpenLayers.Request.GET({<br> url: "http://labs.metacarta.com/wms/vmap0?request=GetCapabilities&service=WMS",<br> success: parseWmsCapabilities,<br> failure: function(response) {}<br>});<br><br>var parseWmsCapabilities = function(response) {<br> var wmsParser = new OpenLayers.Format.WMSCapabilities();<br> var wmsCapabilities = wmsParser.read(response.responseText);<br> for(var i=0; i<wmsCapabilities.capability.layers.length;
++i) { <br> alert(wmsCapabilities.capability.layers[i].name);<br> }<br>} <br><br>Best regards,<br>Gabriel Nolasco<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><div class="plainMail">Hi all,<br>I want to get WMSGetCapabilites from server. The URL is<br><a href="http://labs.metacarta.com/wms/vmap0?request=GetCapabilities&service=WMS" target="_blank">http://labs.metacarta.com/wms/vmap0?request=GetCapabilities&service=WMS</a> and<br>works fine.<br><br>But when I "execute" the next code the request never ends or returns me a<br>empty response.<br><br>Anybody can help me clarifiying me how to get wms capabilities and later get<br>the available layer names?<br><br>Thanks in advance.<br><br> <html><br> <head><br>
<title></title><br> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><br> <script type="text/javascript" src='./js/ol/OpenLayers.js'></script><br> <script type="text/javascript"><br> request = OpenLayers.Request.GET({<br> url: "<br><a href="http://labs.metacarta.com/wms/vmap0?request=GetCapabilities&service=WMS" target="_blank">http://labs.metacarta.com/wms/vmap0?request=GetCapabilities&service=WMS</a>",<br> success: function(request){<br> alert(request.responseText);<br> },<br> failure:
function(request){<br> alert('BOOOOOO!');<br> }<br><br> });<br> </script><br><br> </head><br> <body><br> the body content<br> </body><br></html><br></div></blockquote></td></tr></table><br>