Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>First you need to define the WCF like below</p> <pre><code> [OperationContract] [WebInvoke(UriTemplate = "/GetAreaNames", RequestFormat = WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] List&lt;Area&gt; GetAreaNames(); </code></pre> <p>or for Multiple Parameters</p> <pre><code>[OperationContract] [WebInvoke(UriTemplate = "/ExcelDataInfo?area={area}&amp;month={month}", RequestFormat =WebMessageFormat.Json, ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped)] void ExcelDataInfo(string area, string month); </code></pre> <p>and after in the Script Page </p> <pre><code>var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4 &amp;&amp; xmlhttp.status == 200) { var Items = JSON.parse(xmlhttp.responseText); var data = Items; var options; var length = Items.GetAreaNamesResult.length; for (var i = 0; i &lt; length; i++) { $("#CbxArea").append("&lt;option&gt;" + Items.GetAreaNamesResult[i].AreaName + "&lt;/option&gt;");//GetAreaNamesReult is your method and AreaName is variable } document.getElementById('CbxArea').selectedIndex = 1; } else { document.getElementById('CbxArea').innerHTML = '&lt;option&gt;Select Area&lt;/option&gt;'; } } xmlhttp.open("POST", "WCFService_url", true); xmlhttp.send(); </code></pre> <p>for passing multiple parameters like below</p> <pre><code> var url = "http://localohost:8090/ExcelDataInfo?area=" + area + "&amp;month=" + month; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload