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
Sneha K
1.2k
527
196.3k
Cant able to load the table in ajax success function mvc
May 13 2021 7:14 AM
Hi all i cant able to load the table values in ajax success function. I tried to load the values of the table in ajax success function.But it not loading the values properly
My Controller
public JsonResult GetData(int ID=3, int PID=1001)
{
try
{
List<Details> grplist= new List<Details>();
var Par = new Parameters();
par.Add("ID",ID);
par.Add("PID",PID);
var grptable = StroredProc..GetDataTable(spGetDetails",par);
for(int i=0;i<grptable .Rows.Count;i++)
{
DetailModel grp= new DetailModel();
grp.name = grptable.Rows[i]["name"];
grp.Relation= grptable.Rows[i]["Relation"];
grplist.Add(grp);
}
return Json( grplist, JsonRequestBehavior.AllowGet);
}
catch (Exception ex)
{
Common.AddModel_Log4Net();
throw new Exception(ex.ToString());
}
}
My View
<div class="row" id="details">
<table class="table table-bordered table-striped mb-none" id="datatable-pList">
<thead>
<tr>
<th style="text-align:left">Name</th>
<th style="text-align:left">Relation</th>
</tr>
</thead>
<tbody id ="prebody">
@if (Model != null)
{
foreach (var item in Model)
{
<tr>
<td style="text-align:left">
@item.name
</td>
<td style="text-align:right">
@item.Relation
</td>
</tr>
}
}
</tbody>
</table>
</div>
My Script
<script>
$('#OperationddlYear10').on('change', function () {
$.ajax({
type: "GET",
url: '@Url.Action("GetData", "Home")',
datatype: "Json",
data: { ID: 3, PID: 1001 },
success: function (data) {
for(i=0;i<data.length;i++)
{
$('prebody').html( $('prebody').html() + '<td>'+data[i].name+'</td>' +
'<td>'+data[i].Relation+'</td>');
}
}
});
});
</script>
Above is my code.Now i want to load the table values in ajax success function on year change event but it is not working any one check and help me to resolve this issue .Thanks.
Reply
Answers (
8
)
XMPP client implementation
Get Drop Down Value .