Advertisement
Guest User

Untitled

a guest
Mar 30th, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. function display(parsed) {
  2. article = document.getElementById("homeArticle");
  3. item = '';
  4. for (var i = 0; i < parsed.length; i++) {
  5. var item = parsed[i];
  6.  
  7. var name = item.P_NAME;
  8. var description = item.P_DESCRIPTION;
  9. var price = item.P_PRICE;
  10. // next I add to the string that we want to place on the page
  11. item += '<section id="homePageSection"><div><p>Name: ' + name + '</p><p>Description: ' + description + '</p><p>Price: ' + price + '</p></div></section>';
  12. };
  13. article.innerHTML = item;
  14. }
  15.  
  16.  
  17. function getItems() {
  18. var xhr = new XMLHttpRequest();
  19. xhr.onload = function() {
  20. console.log(this.response)
  21. var parsed = JSON.parse(this.responseText);
  22. display(parsed.rows);
  23. };
  24. xhr.open("POST", "displayData.php");
  25. xhr.send();
  26. }
  27.  
  28. window.addEventListener("load", getItems);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement