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
Ramco Ramco
441
3.4k
523k
Refresh DataTable after Add
Jun 2 2021 10:19 AM
Hi
I have below controller & JS. I want to refresh datatable after Add & display message in popup
<table table table-striped table-bordered
" style="
width:100%
" id="
tblLocation">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.Id)
</th>
<th>
@Html.DisplayNameFor(model => model.Description)
</th>
<th>
@Html.DisplayNameFor(model => model.IsActive)
</th>
<th>Action</th>
</tr>
</thead>
<tbody>
@foreach (
var
item
in
Model)
{
<tr
[email protected]
>
<td>
@Html.DisplayFor(modelItem => item.Id)
</td>
<td>
@Html.DisplayFor(modelItem => item.Description)
</td>
<td>
@Html.DisplayFor(modelItem => item.IsActive)
</td>
<td>
<a
class
=
'btn btn-primary btn-sm'
id=
'btnEdit'
><i
class
=
'fa fa-pencil'
></i> Edit</a>
<a
class
=
'btn btn-danger btn-sm'
id=
'btnDelete'
style=
'margin-left:5px'
@{
if
(item.IsActive ==
"N"
)
{
@:disabled=
"disabled"
}
}><i
class
=
'fa fa-trash'
></i> Delete</a>
</td>
</tr>
}
</tbody>
</table>
function
Add() {
var
res = validate();
if
(res ==
false
) {
return
false
;
}
var
objLocation = {
Id: $(
'#txtId'
).val().toUpperCase(),
Description: $(
'#txtDescription'
).val().toUpperCase(),
IsActive: $(
'#txtIsActive'
).val().toUpperCase()
};
$.ajax({
url:
"/Location/Add"
,
data: JSON.stringify(objLocation),
type:
"POST"
,
contentType:
"application/json;charset=utf-8"
,
dataType:
"json"
,
success:
function
() {
$.notify(result.message, {
globalposition:
"top center"
,
//position:"center",
className:
"success"
})
$(
'#myModal'
).modal(
'hide'
);
},
error:
function
(xhr, ajaxOptions, thrownError) {
$(
"#msgModalBody"
).html(
'Status : '
+ xhr.status +
' Error : '
+ thrownError);
$(
"#msgModal"
).modal(
'show'
);
}
});
}
Thanks
Reply
Answers (
3
)
How Jquery Datatable Showing ENtries will get updated
Too many redirects error in MVC application