【问题标题】:How to send server side jquery datatable data to the server using post request如何使用发布请求将服务器端 jquery 数据表数据发送到服务器
【发布时间】:2015-10-07 12:43:12
【问题描述】:

我正在使用服务器端 jquery 数据表,我在我的 c# 程序中使用了简单的 ajax 获取请求并访问了 jquery 数据表数据(如:start、draw、order、search)。但现在我有很多列,所以它不返回数据在使用 get 请求的所有数据表列中,所以我想使用 ajax 发布请求,但我不知道如何访问这些数据表参数(开始、绘制、订单、搜索)并在 ajax 发布请求中传递这些参数。

GET 请求客户端

 "ajax": "/Admin/InterestsJson"

服务器端: C#

NameValueCollection nvc = HttpUtility.ParseQueryString(Request.Url.Query);
string sEcho = nvc["draw"];
int iDisplayStart = Convert.ToInt32(nvc["start"]);
string searchValue = nvc["search[value]"];
int orderColumn = Convert.ToInt32(nvc["order[0][column]"]);
string orderDir = nvc["order[0][dir]"];

发布请求:客户端

"ajax": {
"url": "/Admin/SubInterestsJson",
"type": "POST"
}

请告诉我如何访问这些jquet数据表参数并传入post请求?

【问题讨论】:

  • 您已经将请求类型更改为POST"type": "POST"。如果您使用"serverSide": true" 启用服务器端处理模式,DataTables 将为您传递这些参数。
  • 我已经在使用 bServerSide": true 但没有在服务器端获取值

标签: c# datatables


【解决方案1】:

对于 POST 请求:

如果您发送 POST 请求,请在服务器端使用以下代码:

string sEcho = Request.Params["draw"];
int iDisplayStart = Convert.ToInt32(Request.Params["start"]);
string searchValue = Request.Params["search[value]"];
int orderColumn = Convert.ToInt32(Request.Params["order[0][column]"]);
string orderDir = Request.Params["order[0][dir]"];

对于 GET 请求:

以下代码是我之前用于 GET 请求的代码。

NameValueCollection nvc = HttpUtility.ParseQueryString(Request.Url.Query);
string sEcho = nvc["draw"];
int iDisplayStart = Convert.ToInt32(nvc["start"]);
string searchValue = nvc["search[value]"];
int orderColumn = Convert.ToInt32(nvc["order[0][column]"]);
string orderDir = nvc["order[0][dir]"];

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-04-06
    • 1970-01-01
    • 2012-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多