使用多个值将ArrayList元素从Web方法检索到AJAX

时间:2018-07-05 07:21:00

标签: javascript jquery ajax asp.net-ajax

Webmethod

public static Array GetChiefDatapageLoad()
{
    clsDBOperation obj = new clsDBOperation();
    ArrayList arrayList = new ArrayList();
    DataTable ComplaintData = obj.GetDataTable(" select * from  ComplaintData where RegNo='" + HttpContext.Current.Session["RegNo"] + "' and OPDNO='" + HttpContext.Current.Session["NewOPDNo"] + "' and  CONVERT(DATE,EDate) = '" + System.DateTime.Now.ToString("dd-MMM-yyyy") + "'");
    DataTable DiagnosisData = obj.GetDataTable( " select * from  DiagnosisData where RegNo='" + HttpContext.Current.Session["RegNo"] + "' and OPDNO='" + HttpContext.Current.Session["NewOPDNo"] + "' and  CONVERT(DATE,EDate) = '" + System.DateTime.Now.ToString("dd-MMM-yyyy") + "'");
    DataTable MedicalTestData = obj.GetDataTable(" select * from  MedicalTestData where RegNo='" + HttpContext.Current.Session["RegNo"] + "' and OPDNO='" + HttpContext.Current.Session["NewOPDNo"] + "' and  CONVERT(DATE,EDate) = '" + System.DateTime.Now.ToString("dd-MMM-yyyy") + "'");
    if (ComplaintData.Rows.Count > 0)
    {
        for (int i = 0; i < ComplaintData.Rows.Count; i++)
        {
         arrayList.Add(ComplaintData.Rows[i]["Complaint"].ToString());
        }
    }
    if (DiagnosisData.Rows.Count > 0)
    {
        for (int i = 0; i < DiagnosisData.Rows.Count; i++)
        {
         arrayList.Add(DiagnosisData.Rows[i]["Test"].ToString());
        }
    }
    if (MedicalTestData.Rows.Count > 0)
    {
        for (int i = 0; i < MedicalTestData.Rows.Count; i++)
        {
            arrayList.Add(MedicalTestData.Rows[i]["Test"].ToString());
        }
    }
    return arrayList.ToArray();
}

ajax

<script type="text/javascript">
    function ajaxloadchicf() {
        $.ajax({
            type: "Post",
            url: "Prescription.aspx/GetChiefDatapageLoad",
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (response) {
                var chiefcomplaint;
                var orderlab;
                var investigation;
                chiefcomplaint = response.d[0];
                orderlab = response.d[1];
                investigation = response.d[2];
            },
            failure: function (msg) {
                return false;
            }
        });
        return false;
    }
</script>

我想获取由webmethod'arrayList'发送给Ajax的数组列表,但是问题是:

“第一数组列表”的

值与“”成一行,例如:arrayList.Add(ComplaintData.Rows[i]["Complaint"] --> a,b

第二个Arraylist的

值在两行中:arrayList.Add(DiagnosisData.Rows[i]["Test"] --> c 我正在像

这样的Arraylist
datatable -1  arraylist[0] = a,b
datatable -2  arraylist[1] = c
datatable -2  arraylist[2] = d

但是我想在arraylist[0]中显示第一个数据表值,在arraylist[1]中显示第二个数据表值

0 个答案:

没有答案