Commit 20d3b09e by Patryk Czarnik

Pobieranie JSONa w jQuery

parent 465cef80
......@@ -5,17 +5,23 @@
<title>Title</title>
<script src="jquery-3.7.1.min.js"></script>
<script>
$(document).ready(function(event) {
function pobierz() {
$.getJSON("/rest/products", function( data ) {
// console.log(data)
data.forEach((product) => {$("#produkty").append("<p> " + product.productName + " za cenę " + product.price + "</p>")})
});
})
}
$(document).ready(function(event) {
$("#guzik").on("click", pobierz)
})
</script>
</head>
<body>
<h1>Stronka ze skryptem</h1>
<div><button id="guzik">Pobierz produkty</button></div>
<div id="produkty">
</div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment