jquery - Page not modified after call Ajax in MVC4 -


hello new ajax , mvc. trying receive data webapi app in mvc page using jquery ajax having problem page not updating data when check in output of visual studio see received , give http status 200 "ok" in page no data displayed

here goes code of page

@{     viewbag.title = "index";     <script src="~/scripts/jquery-ui-1.8.24.min.js">      </script> }       <script type="text/javascript">         $(document).ready(function ()         {             $.ajax(                 {                     type:'get',                     url: 'http://localhost:45624/api/vehicles/',                     datatype:'json',                     sucess: function(data){                         $.each(data, function (index,element) {                             $("#grid").append("<tr><td>" + element.maker + "</td><td>" + element.model + "</td><td>"                                 + element.bodytype + "</td><td>" + element.drivers + "</td><td>"                                 + element.aquisitiondate + "</td><td>" +                                 "<tr>");                         });             } }                   );         });     </script>   <h2>all companies</h2>  <table id="#grid"><tr>     <td>maker</td><td>model</td><td>body type</td><td>drivers</td>     <td>aqusitiondate</td><td>images</td><td>schedules</td><td>maintenances</td>         </tr>     </table> 

i tried use alert nothing when try google chrome , add error option need refresh 3 times error debugging ie10

got it!

everytime write jquery ajax code, double-check spelling.

they commented id="#grid" thing, $.ajax doesn't have member called sucess. , datatype should datatype. should notice javascript case-sensitive.

replace sucess success , datatype datatype. code shoud this:

   $(document).ready(function ()     {         $.ajax(             {                 type:'get',                 url: 'http://localhost:45624/api/vehicles/',                 datatype:'json',                 success: function(data){                     $.each(data, function (index,element) {                         $("#grid").append("<tr><td>" + element.maker + "</td><td>" + element.model + "</td><td>"                             + element.bodytype + "</td><td>" + element.drivers + "</td><td>"                             + element.aquisitiondate + "</td><td>" +                             "<tr>");                     });               }           });     }); 

brotip: http://localhost:45624/api/vehicles/ can written @url("vehicles", "api") think. dont remember right: @url("vehicles", "api") or @url("api", "vehicles"). use someday, try writing this.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -