-
Notifications
You must be signed in to change notification settings - Fork 0
/
DataAddingJson.html
48 lines (43 loc) · 1.9 KB
/
DataAddingJson.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<html>
<head>
<script src="jquery-3.1.1.js"></script>
<script>
$(document).ready(function(){
var data="";
var d=new Date();
$("#btn1").on('click',function(){
data+=$("#text1").val();
// data+=$("#text2").val();
// data+=$("#text3").val();
$("#displayData").html(d);
var sendInfo = {
"author": data,
"date": d
};
var d2=JSON.stringify(sendInfo);
$.ajax({
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json'
},
type: "POST",
//the url where you want to sent the userName and password to
url: 'http://localhost:8080/JerseyMessaging/webapi/messagesJson',
dataType: 'json',
//json object to sent to the authentication url
data: d2,
success: function () {
alert("Thanks!");
}
});
});
});
</script>
</head>
<body>
<h1 align="center">Welcome to Chat Room</h1>
ENTER THE AUTHOR NAME: <input type="text" id="text1"><br/>
<input type="button" id="btn1" value="display Data">
<div id="displayData"></div>
</body>
</html>