Note that there are some explanatory texts on larger screens.

plurals
  1. POJquery separate list items AJAX
    primarykey
    data
    text
    <pre><code> public class searchResult { public int id; public string name; } /// &lt;summary&gt; /// Summary description for WebService1 /// &lt;/summary&gt; [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [ToolboxItem(false)] [System.Web.Script.Services.GenerateScriptType(typeof(searchResult))] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. [System.Web.Script.Services.ScriptService] public class WebService1 : System.Web.Services.WebService { [WebMethod] public searchResult[] Search(int txtSearch) { //Semuler to slow internet connection System.Threading.Thread.Sleep(2000); //Declare collection of searchResult List&lt;searchResult&gt; resultList = new List&lt;searchResult&gt;(); DataSet ds = Classes.getEmployeeDetailSet("SELECT [Employee ID],[First Name] FROM [Employee$] WHERE [Employee ID] like '" + txtSearch + "%'"); DataTable dt = new DataTable(); dt = ds.Tables[0]; if (dt.Rows.Count &gt; 0) { searchResult result = new searchResult(); result.id = int.Parse(dt.Rows[0]["Employee ID"].ToString()); result.name = dt.Rows[0]["First Name"].ToString(); resultList.Add(result); } return resultList.ToArray(); } </code></pre> <p>i have created a list like </p> <pre><code> List&lt;searchResult&gt; resultList = new List&lt;searchResult&gt;(); this and i have return that list to call this i have use ajax code like this $.ajax({ type: "POST", url: "WebService1.asmx/Search", //function that in web service data: "{txtSearch:" + $("#txtSearch").val() + "}", // passing value of txtSearch input contentType: "application/json; charset=utf-8", dataType: "json", success: function(response) { var result = response.d; var value = ''; $.each(result, function(index, res) { value = value + res.id + res.name; }); alert(value); alert("Record was updated successfully,,"); }, error: function(msg) { alert("Error while calling web service,,"); } }); </code></pre> <p>My problem is that I am getting only one element from the database </p> <p>I think I am not able to separate the list in the ajax response here</p> <pre><code> $.each(result, function(index, res) { value = value + res.id + res.name; }); </code></pre> <p>I want to create a array with use of this id+name</p> <p>please help</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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