Bobindra Kumar

Bobindra Kumar

  • 1.4k
  • 324
  • 12.4k

Uncaught TypeError: setData.append is not a function

May 4 2018 3:38 AM
@model CrudPopupJquery.Models.EmployeeViewModel
@{
Layout = null;
}
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script src="~/Scripts/bootstrap.min.js"></script>
<link href="~/Content/bootstrap.min.css" rel="stylesheet" />
<div class="container" style="margin-top:3%">
<a href="#" class="btn btn-info" onclick="AddNewstudent(0)">Add New Employee</a><br/><br />
<table class="table table-striped" >
<thead>
<tr>
<th>EmpId</th>
<th>EmpName</th>
<th>EmailId</th>
<th>PhoneNo</th>
<th>Action(Edit)</th>
<th>Action(Delete)</th>
</tr>
</thead >
<tbody id="SetStudentList">
<tr id="LoadingStatus" style="color:red">
</tr>
</tbody>
</table>
</div>
<script>
$("#LoadingStatus").html("Loading...");
$.get("Home/GetStudentList", null, DataBind);
$.noConflict();
function DataBind(StudentList)
{
alert('hi');
var SetData = ("#SetStudentList");
for (var i = 0; i < StudentList.length; i++)
{
var Data = "<tr class='row_" + StudentList[i].EmpId + "'>"+
"<td>" + StudentList[i].EmpId + "<td>"+
"<td>" + StudentList[i].EmpName + "<td>"+
"<td>" + StudentList[i].EmailId + "<td>"+
"<td>" + StudentList[i].PhoneNo + "<td>"+
"<td>"+"<a href='#' class='btn btn-warning' onclick='Editstudent()'><span class='glyphicon glyphicon-edit'></span></a>"+"</td>"+
"<td>"+"<a href='#' class='btn btn-danger' onclick='Deletestudent()'><span class='glyphicon glyphicon-trash'></span></a>"+"</td>"+
"<tr>";
//setData.append(Data);
SetData.apeend(Data);
$("#LoadingStatus").html(" ");
}
}
</script>

Answers (4)

1
Manav Pandya

Manav Pandya

  • 0
  • 19.9k
  • 2.3m
May 4 2018 6:07 AM
Hello
 
Observe my code what i have provided to you , do not judge by just watching content
 
Thanks 
1
Bobindra Kumar

Bobindra Kumar

  • 1.4k
  • 324
  • 12.4k
May 4 2018 6:03 AM
if i am taking var SetData = $("#SetStudentList"); then my function is not calling and whenever i am not taking $ before this when function is calling but getting this error
Uncaught TypeError: SetData.append is not a function
1
Bobindra Kumar

Bobindra Kumar

  • 1.4k
  • 324
  • 12.4k
May 4 2018 5:24 AM
Sir All changes already corrected but i am still getting same error
1
Manav Pandya

Manav Pandya

  • 0
  • 19.9k
  • 2.3m
May 4 2018 5:01 AM
Hello
 
From the first view , you have mistaken about spelling :
 
Written : 
 
SetData.apeend(Data);
 
Should be :
 
SetData.append(Data);
 
Correct code :
  1. <!DOCTYPE html>    
  2. <html>    
  3. <head>    
  4. <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>    
  5. <script>    
  6. $(document).ready(function(){    
  7.          
  8.       alert('hi');    
  9.       var SetData = $("#SetStudentList");    
  10.          
  11.       var Data = "<tr class='row_" + 1 + "'>"+    
  12.       "<td>1</td>"+    
  13.       "<td>Manav</td>"+    
  14.       "<td>a@b.com</td>"+    
  15.       "<td>1234567891</td>"+    
  16.       "<td>Edit</td>"+    
  17.       "<td>Delete</td>"+    
  18.       "<tr>";    
  19.       //setData.append(Data);    
  20.       SetData.append(Data);    
  21.         
  22.          
  23. });    
  24. </script>    
  25. </head>    
  26. <body>    
  27.     
  28. <table border="5" class="table table-striped" >    
  29. <thead>    
  30.   <tr>    
  31.   <th>EmpId</th>    
  32.   <th>EmpName</th>    
  33.   <th>EmailId</th>    
  34.   <th>PhoneNo</th>    
  35.   <th>Action(Edit)</th>    
  36.   <th>Action(Delete)</th>    
  37.   </tr>    
  38. </thead >    
  39. <tbody id="SetStudentList">    
  40. </tr>    
  41. </tbody>    
  42. </table>    
  43.     
  44. </body>    
  45. </html>
EmpIdEmpNameEmailIdPhoneNoAction(Edit)Action(Delete)
1 Manav a@b.com 1234567891 Edit Delete
 
List of mistake
 
- you have not specified $ during gettingcontent of : 
 
var SetData = ("#SetStudentList"); // add $ before
 
- unclosed tags 
 
- You can put function outside document.ready and can call whenever you want
 
I think above solution will help you
 
Thanks