Skip to content

Instantly share code, notes, and snippets.

@EricCote
Last active February 22, 2017 20:55
Show Gist options
  • Save EricCote/bbed62646259b4b2a07b352887a79864 to your computer and use it in GitHub Desktop.
Save EricCote/bbed62646259b4b2a07b352887a79864 to your computer and use it in GitHub Desktop.
Mercredi
/// <reference path="jquery-3.1.1.js" />
$(function () {
$("#btnEmployes").click(function () {
var httpRequest = new XMLHttpRequest();
httpRequest.addEventListener("readystatechange",
function () {
if (httpRequest.readyState ===
XMLHttpRequest.DONE) {
var table =
$('<table class="table table-striped"></table>')
var thead = $("<thead><tr><th>Nom</th><th>Poste</th><th>Date embauche</th> <tr></thead>");
var tbody = $("<tbody></tbody>");
$(table).append(thead).append(tbody);
var liste = JSON.parse(httpRequest.responseText);
$.each(liste, function (i, emp) {
var row = $("<tr><td>" + emp.nom +
"</td><td>" + emp.poste +
"</td><td>" + emp.dateEmbauche + "</td></tr>");
$(tbody).append(row);
});
$("#sectionEmploye").append(table);
} else {
}
});
httpRequest.open("GET", "/employes", true);
httpRequest.send(null);
});
});
...
var jsonformatter =
GlobalConfiguration.Configuration.Formatters.JsonFormatter;
jsonformatter.SerializerSettings.ContractResolver =
new CamelCasePropertyNamesContractResolver();
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment