0

嗨,我有一个 Web 方法,它可以将数据库的数据传递给 jquery ajax 函数,但我不知道它可以将 arraylist 传递给 jquery 并且 jquery 能够识别它或不能识别它,如果答案是好的 ,我如何使用数组列表在 jquery ajax中。它是我的代码

  [WebMethod]
    public ArrayList bringdata()
    {
        SqlConnection con = new SqlConnection("data source=.;database=site;integrated security=true;");
        int cnt;
        string sSQL = "Select username ,average,weight,point , Rank() over(order by point desc) as 'ranking' from karbar order by point desc";
        SqlCommand cmd = new SqlCommand(sSQL, con);

        SqlDataAdapter adapt = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        adapt.Fill(ds);
        ArrayList arrlst = new ArrayList();
        foreach (DataRow row in ds.Tables[0].Rows)
        {
            arrlst.Add(row);
        }
        return arrlst;


    }

请在 jquery 代码中帮助我使用arraylist。非常感谢

4

1 回答 1

0
<script type = "text/javascript">
function Getdata() {
    PageMethods.bringdata(OnSuccess);
}
function OnSuccess(response) {       
    for (var i in response) {
        alert(response[i]);
    }
} 
</script>

而不是警报,您将编写代码以根据需要在页面上附加数据。

于 2012-08-05T09:07:26.807 回答