ajax call to the front desk and spell spelling cycle html

ajax call to the front desk and spell spelling cycle html

 

asp Code

 

$(function () {
   $("#btnShearch").click(function () {

 

       $.ajax({
           type: "Post",
           url: "SearchSentence.aspx/getSearchList",
           data: "{'Sentence': '" + Sentence + "'," + "'chk_SynonymsUsed': '" + chk_SynonymsUsed + "','chk_UnnecessaryWordsUsed':'" + chk_UnnecessaryWordsUsed + "','MaximumRows':'" + MaximumRows + "'}",
           contentType: "application/json;charset=utf-8",
           dataType: "json",
           success: function (data) {
               var rsStr = data.d;

 

               // チェックエラーの場合
               if (rsStr.substr(0, 4) == ("エラー:")) {
                   var errArr = rsStr.split(":");
                   showMessageDialog(errArr[1], errArr[0]);
                   document.getElementById("content_contentFooter_footer_message").innerText = "XXXX..."
                   return;
               }

 

               data = jQuery.parseJSON(rsStr);
               var itemRow = "<table style=\"display: block; overflow-x: auto; overflow-y: auto; overflow: auto \" >";

 

               itemRow += "<tbody>";

 

               $.each(data, function (i, item) {
                   itemRow += "<tr>";
                   for (var k in item) {
                       itemRow += "<td class=\"ell2\"  onclick=cellClick(this)>" + (null == item[k] ? "" : item[k]) + "</td>";
                   }
                   itemRow += "</tr>";
               })

 

               itemRow += "</tbody>";

 

               itemRow += "</table>";
               $("#divItems").html(itemRow);
               SetTbBgcolor();

 

               document.getElementById ( "content_contentFooter_footer_message"). innerText = " You have searched completed."
               //
               document.getElementById ( "DivItemsF"). Style.Display = 'Block'
               document.getElementById ( "BtnShearch"). Disabled = False
               Document. . GetElementById ( "BtnShearch") Focus ();
           },
           error: Function (Err) {
               ( "it is." "back-end processing failed error." Tasu Err.ResponseText Tasu) Alert;
           }
       });
   } );
});
. . .
<Div Id = "DivItemsF" Style = "Overflow-X: Auto; Overflow-Y: Auto">
    <Table Id = "DivItems"

###############################################################
cs代码
[WebMethod]
 public static string getSearchList(string Sentence, bool chk_SynonymsUsed, bool chk_UnnecessaryWordsUsed, string MaximumRows)
{
   
    DataTable searchSentenceDataTable = null;

 

    the try
    {
        // data acquisition
        searchSentenceDataTable = dao.getSearchSentenceList (Sentence);

 

    return DataTableToJSON(searchSentenceDataTable);
}

 

// DataTable转换成JSON格式
 [WebMethod]
public static string DataTableToJSON(DataTable table)
{
    var list = new List<Dictionary<string, object>>();

 

    foreach (DataRow row in table.Rows)
    {
        var dict = new Dictionary<string, object>();

 

        foreach (DataColumn col in table.Columns)
        {
            dict[col.ColumnName] = row[col];
        }
        list.Add(dict);
    }

 

    JavaScriptSerializer serializer = new JavaScriptSerializer();
    string str = serializer.Serialize(list);
    return str;
}


/// Array数组转换成DataTable
public static DataTable ArrayToDataTable(string[,] arr)
{
    DataTable dataSouce = new DataTable();
    for (int i = 0; i < arr.GetLength(1); i++)
    {
        DataColumn newColumn = new DataColumn(i.ToString(), arr[0, 0].GetType());
        dataSouce.Columns.Add(newColumn);
    }
    for (int i = 0; i < arr.GetLength(0); i++)
    {
        DataRow newRow = dataSouce.NewRow();
        for (int j = 0; j < arr.GetLength(1); j++)
        {
            newRow[j.ToString()] = arr[i, j];
        }
        dataSouce.Rows.Add(newRow);
    }
    return dataSouce;
}

Guess you like

Origin blog.csdn.net/wxmwzz/article/details/91563051