Retrieve value from webservice called from javascript?
<p>Is it possible to retrieve value or date from calling a webmethode from javascript, here is a sample code:</p>

<pre><code>//This method is in a webservice.asmx file.
[WebMethod]
public List&lt;tbl_City&gt; GetAllCitiesByCountry(int countryID)
{

    return Cities.GetAllCitiesByCountry(CountryID: countryID);
}


&lt;script language="javascript" type="text/javascript"&gt;

function fillCities() {
    var dropDownList = document.getElementById('&lt;%=DropDownList_Country.ClientID %&gt;');
    var selectedIndex = dropDownList.selectedIndex;
    var value = dropDownList[selectedIndex].value;

   WebService.GetAllCitiesByCountry(parseInt(value.toString()), onSuccess, null, "");

}

   function onSuccess(result){
      alert(result[0].(PropertyName));
      }
</code></pre>

<p></p>

<p>The variable x doesn't retrieve anything and I guess that it produce an error. I have tried to define an array but still it didn't work. Any idea ?</p>

<p><strong>Edit:</strong></p>

<p>The above code have been altered and is now an answer to my question along with the answer below which used JQuery.</p>
