'Getting data from JSON-Server to local JQuery
Local HTML and JSON-Server data. Getting the data from JSON-Server and using it in JQuery.
Resolved with help of Kevin B and Sirko. Leaving the JS (JQuery) so it can be coppied in the future.
var i = 0;
var output;
$("#send").click(function(e) {
$.getJSON("http://localhost:3000/db", function(data) {})
.done(function(json) {
$.each(json, function(key, val) {
output+= '<p>name=' + json[i].name + '</p>';
i++;
});
$("#paragraph").append(output);
})
.fail(function(jqxhr, textStatus, error) {
var err = textStatus + ", " + error;
console.log("Request Failed: " + err);
});
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
