Quantcast
Channel: ASP.NET AJAX + Ajax Control Toolkit (ACT)
Viewing all articles
Browse latest Browse all 5678

return more than one value with ajax in web method

$
0
0

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.


Viewing all articles
Browse latest Browse all 5678

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>