Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function display(parsed) {
- article = document.getElementById("homeArticle");
- item = '';
- for (var i = 0; i < parsed.length; i++) {
- var item = parsed[i];
- var name = item.P_NAME;
- var description = item.P_DESCRIPTION;
- var price = item.P_PRICE;
- // next I add to the string that we want to place on the page
- item += '<section id="homePageSection"><div><p>Name: ' + name + '</p><p>Description: ' + description + '</p><p>Price: ' + price + '</p></div></section>';
- };
- article.innerHTML = item;
- }
- function getItems() {
- var xhr = new XMLHttpRequest();
- xhr.onload = function() {
- console.log(this.response)
- var parsed = JSON.parse(this.responseText);
- display(parsed.rows);
- };
- xhr.open("POST", "displayData.php");
- xhr.send();
- }
- window.addEventListener("load", getItems);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement