How to Call Web API Get with jQuery

It is easier to create REST based web services based on Web API than to call them inside web pages. Below is a sample call (GET) to Web API service using jQuery.
 <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-2.0.3.min.js"></script>
    var uri = 'api/licences';

    $(document).ready(function () {
      // Send an AJAX request
          .done(function (data) {
            // On success, 'data' contains a list of licences.
            $.each(data, function (key, item) {
              // Add a list item for the product.
              $('<li>', { text:item }).appendTo($('#products'));

No comments:

Post a Comment