im trying to fetch the data from the table using ajax , its working great but my query is asking for 3 values from the table row , im only getting 1
below is my code
<script>$(document).ready(function () {
//$("#btntst").click(function() {$("#askme").keyup(function () {$("#ora").empty();$.ajax({
type: "POST",
url: "Default.aspx/GetData",
data: "{'Word' : '" + $("#askme").val() + "'}",
dataType: "json",
contentType: "application/json; charset=utf-8",
success: function (res) {
// alert(res.d);
$("#ora").append(res.d);
},
error: function (xhr, textStatus, err) {
alert("readyState: " + xhr.readyState);
alert("responseText: " + xhr.responseText);
alert("status: " + xhr.status);
alert("text status: " + textStatus);
alert("error: " + err);
}
});
});
});
</script>webmethod:
public static string GetData(string Word) {
string sql = " SELECT meaning, syn1, syn2 from tbl_dic where Word=N'" + Word +"'" ;
DataTable DATA = new DataTable();
SqlDataAdapter dta = new SqlDataAdapter(sql,con);
dta.Fill(DATA);
if(DATA.Rows.Count > 0 ) {
return DATA.Rows[0].ItemArray[1].ToString();
}
return "";
}IM ONLY GETTING ONE VALUE , CAUSE ITEM ARRAY IS [1] , I CANT FIGURE OUT HOW TO RETURN ALL THE VALUE .... IS IT USING A LOOP OR ????
ANY HELP WOULD BE APPRECIATED.