Watch Pre-recorded Live Shows Here
Why Join
Become a member
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
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
Ramco Ramco
1.4k
723
46.7k
Error on Ajax Reload
Jun 1 2021 4:52 PM
Hi
On this line i get error - $('#tblLocation').DataTable().ajax.reload();
DataTables warning: table id=tblLocation - Invalid JSON response. For more information about this error, please see http://datatables.net/tn/1
@foreach (var item in Model)
{
}
@Html.DisplayNameFor(model => model.Id)
@Html.DisplayNameFor(model => model.Description)
@Html.DisplayNameFor(model => model.IsActive)
Action
@Html.DisplayFor(modelItem => item.Id)
@Html.DisplayFor(modelItem => item.Description)
@Html.DisplayFor(modelItem => item.IsActive)
Edit
Delete
****************************8
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 (result) {
$('#tblLocation').DataTable().ajax.reload();
$.notify(result.message, {
globalposition: "top center",
className:"success"
})
$('#myModal').modal('hide');
},
error: function (xhr, ajaxOptions, thrownError) {
$("#msgModalBody").html('Status : ' + xhr.status + ' Error : ' + thrownError);
$("#msgModal").modal('show');
}
});
}
***************************************
public List<Location> GetAllLocation()
{
List<Location> objLocation = new List<Location>();
using (SqlConnection con = new SqlConnection(cs))
{
con.Open();
SqlCommand com = new SqlCommand("sp_Location", con);
com.CommandType = CommandType.StoredProcedure;
com.Parameters.AddWithValue("@Action", "R");
SqlDataReader rdr = com.ExecuteReader();
while (rdr.Read())
{
objLocation.Add(new Location
{
Id = rdr["Id"].ToString(),
Description = rdr["Description"].ToString(),
IsActive = rdr["IsActive"].ToString(),
});
}
return objLocation;
}
}
Thanks
Reply
Answers (
5
)
Error - Uncaught ReferenceError: HR is not defined at HTMLAnchorE
Passing a string parameter to EF REST API using asp.net core 3.1