Advertisement
Guest User

Untitled

a guest
Nov 1st, 2014
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var URL_BASE = "http://localhost:8080/eBarRest/rest/eBar";
  2. var commandId = -1;
  3.  
  4. $(document).ready(function() {
  5.     if ($('#carte').size() != 0) {
  6.         $.ajax({
  7.             url: URL_BASE + "/bieres",
  8.             type: "GET",
  9.             data: {
  10.                 mot: ""
  11.             },
  12.             dataType: "json",
  13.             accepts: {"json": "application/json"},
  14.             async: false
  15.         })
  16.         .done(function (response, textStatus, xhr) {
  17.             if (response['bieres'] == null)
  18.                 return;
  19.  
  20.             var html = "";
  21.  
  22.             for (var i = 0; i < response['bieres'].length; i++) {
  23.                 html += "<tr>";
  24.                 html += "<td>" + response['bieres'][i]['nom'] + "</td>";
  25.                 html += "<td>" + response['bieres'][i]['type'] + "</td>";
  26.                 html += "<td>" + response['bieres'][i]['couleur'] + "</td>";
  27.                 html += "<td>" + response['bieres'][i]['prix'] + "</td>";
  28.                 html += "</tr>";
  29.             };
  30.  
  31.             $('#carte').append(html);
  32.  
  33.             // commandId = $(response).children("Commande").children("id").eq(0).text();
  34.         })
  35.         .fail(function (xhr, textStatus, errorThrown) {
  36.             console.log(textStatus);
  37.             console.log(errorThrown);
  38.         });
  39.     }
  40. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement