ahmed salah

ahmed salah

  • NA
  • 530
  • 142k

json data not show in table when click button jquery

Jul 23 2016 11:37 PM
I have url www.DevuEgypt.com/api/employees i need to display FirstName,Id,Salary in table by click button using jquery
when click button not give me any result and give me two message
I try more time but it give me error
submit handler has fired this is normal to check
error error not found this message show to me
my code as below
  1. @{  
  2.     Layout = null;  
  3. }  
  4.   
  5. <!DOCTYPE html>  
  6.   
  7. <html>  
  8. <head>  
  9.     <meta name="viewport" content="width=device-width" />  
  10.     <title>Index</title>  
  11.   
  12.     <script src="~/Scripts/jquery-1.10.2.js"></script>  
  13.     <script>  
  14.         $(function () {  
  15.             $('#btn').click(function () {  
  16.                alert("submit handler has fired");  
  17.                 $.ajax({  
  18.                    // type: 'POST',  
  19.                     url: 'www.DevuEgypt.com/api/employees',  
  20.                     data:{},  
  21.                     dataType: 'json',  
  22.   
  23.                     success: function (data) {  
  24.                         $.each(data, function (index, value) {  
  25.                            var row = $("<tr><td>" + value.FirstName + "</td><td>" + value.Id + "</td><td>" + value.Salary + "</td></tr>");  
  26.                           $("#myData").append(row);  
  27.                          });  
  28.                      
  29.                     },  
  30.                    error: function (jqXHR, textStatus, errorThrown) {  
  31.                         alert('error: ' + textStatus + ': ' + errorThrown);  
  32.                    }  
  33.                 });  
  34.                 //return false;//suppress natural form submission  
  35.             });  
  36.         });  
  37.     </script>  
  38. </head>  
  39. <body>  
  40.     <div>   
  41.         <input type="button" value="GetData" id="btn" />  
  42.         <table id="myData"></table>  
  43.     </div>  
  44. </body>  
  45. </html>  
 
 

Answers (1)