Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to send server side jquery datatable data to the server using post request

Tags:

c#

datatables

I am using server side jquery datatable and i used the simple ajax get request and accessed jquery datatable data(like:start,draw,order,search) in my c# program.But now i have many columns so its not returing data of all datatable columns using get request so i want to use the ajax post request but i don't know how to access these datatable parameters(start,draw,order,search) and pass these in ajax post request.

GET Request: Client Side

 "ajax": "/Admin/InterestsJson"

Server Side: 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]"];

Post Request:Client side

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

Please tell me how to access these jquet datatable parameters and pass in post request?

like image 729
Floki Avatar asked Nov 17 '25 18:11

Floki


1 Answers

For POST request:

If you are sending POST request, use the following code on the server side like:

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]"];

For GET request:

The following code is what I used before for GET request.

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]"];
like image 185
Floki Avatar answered Nov 20 '25 08:11

Floki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!