Message from JavaScript discussions

June 2017

— And in that page the data (from other json) will appear based on the menu that i click

— 

So e.g
this is my menu

1. Menu 1 -> Id 1
2. Menu 2 -> Id 2

this is my page
1. page 1 -> id 1 , menu_id : 1
2. page 2 -> id 2, menu_id : 2

how to make the page based on the menu? i am fail in this step

— You can add event listeners on your menu, then do some json request and show it as page.

— Ex :
<button id="q">page 1</button>
<div id="page"></div>
<script>

— Document.getElementById("q").addEventListener("click", function(){
var a = new XMLHttpRequest();
a.open("GET","/page1.json",true);
a.onload = function(){
var q = JSON.parse(this.responseText);
document.getElementById("page").innerHTML += q['page'];
};
a.send(null);
});

</script>

Message permanent page

— Json : {"page": "hello world"}

— Can u tell me about this

var q = JSON.parse(this.responseText);
document.getElementById("page").innerHTML += q['page'];

?

Message permanent page

— Wait, i will test it first

— Https://www.crayner.cf/test/test.html

— Https://www.crayner.cf/test/page1.json

— You can use innerHTML for change the HTML content

— JSON.parse()