-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdynamic.html
31 lines (30 loc) · 921 Bytes
/
dynamic.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!DOCTYPE html>
<html>
<head>
<title id="header"></title>
</head>
<body>
<h1 id="h1"></h1>
<img id="image" src=""><br><hr>;
<p id="body"></p>;
<script>
var xhttp=new XMLHttpRequest();
xhttp.open("POST","http://koushikmln.com:7500/blogs/getBlog",true);//true defines asynchronous requests
//send headers
xhttp.setRequestHeader("Content-type","application/json");
var id=localStorage.getItem("id");
var obj={"blogId":id};
xhttp.send(JSON.stringify(obj));
xhttp.onreadystatechange = function()
{
if(this.readyState == 4 && this.status == 200){
var x=JSON.parse(this.responseText);
document.getElementById("header").innerHTML=x.title;
document.getElementById("h1").innerHTML=x.title;
document.getElementById("image").src=x.imageUrl;
document.getElementById("body").innerHTML=x.content;
}
}
</script>
</body>
</html>