TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Sanjay gautam
NA
90
14.2k
split datatable and send it to ajax response one by one
Oct 10 2019 12:39 AM
Hello guys i have some code i have done parfectly splitting but i am tired to send it one by one with time interval please help me
<
center
>
<
input
type
=
"button"
id
=
"btn"
value
=
"Get Data"
/>
<
div
>
<
table
id
=
"tbl"
>
<
tr
>
<
th
>
Id
</
th
>
<
th
>
Name
</
th
>
<
th
>
Address
</
th
>
<
th
>
Phone
</
th
>
<
th
>
Email
</
th
>
<
th
>
Project
</
th
>
<
th
>
Role
</
th
>
<
th
>
Status
</
th
>
<
th
>
Completion
</
th
>
</
tr
>
</
table
>
<!--<div id="output"></div>-->
</
div
>
</
center
>
<script type=
"text/javascript"
>
$(document).ready(
function
() {
// var myjson = JSON.stringify(Employee);
$(
'#btn'
).on(
'click'
,
function
() {
$.ajax({
type:
'Post'
,
url:
"/api/com_serialize_data"
,
// data: myjson,
//dataType: 'json',
contentType:
"application/json; charset=utf-8;Content-Encoding=gzip"
,
// ContentEncoding: gzip,
success:
function
(response) {
var
employees = JSON.parse(response);
var
tr;
for
(
var
i = 0; i < employees.length; i++) {
tr = $(
'<tr/>'
);
tr.append(
"<td>"
+ employees[i].Id +
"</td>"
);
tr.append(
"<td>"
+ employees[i].Name +
"</td>"
);
tr.append(
"<td>"
+ employees[i].Address +
"</td>"
);
tr.append(
"<td>"
+ employees[i].Phone +
"</td>"
);
tr.append(
"<td>"
+ employees[i].Email +
"</td>"
);
tr.append(
"<td>"
+ employees[i].Project +
"</td>"
);
tr.append(
"<td>"
+ employees[i].Role +
"</td>"
);
tr.append(
"<td>"
+ employees[i].Status +
"</td>"
);
tr.append(
"<td>"
+ employees[i].Completion +
"</td>"
);
$(
'#tbl'
).append(tr);
$(
'tr'
)
}
},
error:
function
(errorThrown) {
alert(errorThrown);
}
});
});
});
</script>
public
class
com_serialize_dataController : ApiController
{
[HttpPost]
public
async Task <
string
> Employee()
{
DataTable dt =
new
DataTable();
dt.Columns.AddRange(
new
DataColumn[9] {
new
DataColumn(
"Id"
,
typeof
(
int
)),
new
DataColumn(
"Name"
,
typeof
(
string
)),
new
DataColumn(
"Address"
,
typeof
(
string
)),
new
DataColumn (
"Phone"
,
typeof
(
string
)),
new
DataColumn (
"Email"
,
typeof
(
string
)),
new
DataColumn (
"Project"
,
typeof
(
string
)),
new
DataColumn(
"Role"
,
typeof
(
string
)),
new
DataColumn (
"Status"
,
typeof
(
string
)),
new
DataColumn(
"Completion"
,
typeof
(
string
))
});
for
(
int
i = 0; i < 1000; i++)
{
dt.Rows.Add(i,
"Ashok We've also got a Draw counter. This is important, because DataTables ke var j = 1;eps a count of the number of times it 00redraws the table. Every time you interact with thej++table, DataTables fetches the data again from the server. It also increments that counter. When the call comes back with the data, the Draw parameter needs to be there with that same value or we'll get an error. You can read more about the parameters here: DataTables: Server Side"
,
"Faridabad We've also got a Draw counter. This is important, because DataTables keeps a count of the number of times it redraws the table. Every time you interact with the table, DataTables fetches the data again from the server. It also increments that counter. When the call comes back with the data, the Draw parameter needs to be there with that same value or we'll get an error. You can read more about the parameters here: DataTables: Server Side"
,
"0654546644 We've also got a Draw counter. This is important, because DataTables keeps a count of the number of times it redraws the table. Every time you interact with the table, DataTables fetches the data again from the server. It also increments that counter. When the call comes back with the data, the Draw parameter needs to be there with that same value or we'll get an error. You can read more about the parameters here: DataTables: Server Side"
,
"
[email protected]
We've also got a Draw counter. This is important, because DataTables keeps a count of the number of times it redraws the table. Every time you interact with the table, DataTables fetches the data again from the server. It also increments that counter. When the call comes back with the data, the Draw parameter needs to be there with that same value or we'll get an error. You can read more about the parameters here: DataTables: Server Side"
,
"Signage We've also got a Draw counter. This is important, because DataTables keeps a count of the number of times it redraws the table. Every time you interact with the table, DataTables fetches the data again from the server. It also increments that counter. When the call comes back with the data, the Draw parameter needs to be there with that same value or we'll get an error. You can read more about the parameters here: DataTables: Server Side"
,
"Devloper We've also got a Draw counter. This is important, because DataTables keeps a count of the number of times it redraws the table. Every time you interact with the table, DataTables fetches the data again from the server. It also increments that counter. When the call comes back with the data, the Draw parameter needs to be there with that same value or we'll get an error. You can read more about the parameters here: DataTables: Server Side"
,
"Progress We've also got a Draw counter. This is important, because DataTables keeps a count of the number of times it redraws the table. Every time you interact with the table, DataTables fetches the data again from the server. It also increments that counter. When the call comes back with the data, the Draw parameter needs to be there with that same value or we'll get an error. You can read more about the parameters here: DataTables: Server Side"
,
"02/12/2019 We've also got a Draw counter. This is important, because DataTables keeps a count of the number of times it redraws the table. Every time you interact with the table, DataTables fetches the data again from the server. It also increments that counter. When the call comes back with the data, the Draw parameter needs to be there with that same value or we'll get an error. You can read more about the parameters here: DataTables: Server Side"
);
}
var totalRows = dt.Rows.Count;
var halfway = totalRows / 2;
var firstHalf = dt.AsEnumerable().Take(halfway).CopyToDataTable();
var secondHalf = dt.AsEnumerable().Skip(halfway).Take(totalRows - halfway).CopyToDataTable();
if
()
{
return
JsonConvert.SerializeObject(firstHalf);
}
await Task.Delay(1000);
return
JsonConvert.SerializeObject(secondHalf);
}
}
Reply
Answers (
2
)
too many automatic redirections were attempted webclient c#
how to get a middle string value in split