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 GetAllLocation()
{
List objLocation = new List();
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

Sachin SinghRank #66 · 26.2K reputationPosted Jun 2, 2021, 3:32 AM EDT
Asma KhalidRank #160 · 14.7K reputationPosted Jun 2, 2021, 3:17 AM EDT
Ramco RamcoRank #462 · 5.4K reputationPosted Jun 2, 2021, 3:41 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jun 2, 2021, 3:52 AM EDT
Ramco RamcoRank #462 · 5.4K reputationPosted Jun 2, 2021, 4:33 AM EDT