-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclient.js
More file actions
38 lines (35 loc) · 1.04 KB
/
client.js
File metadata and controls
38 lines (35 loc) · 1.04 KB
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
var postEntry = function(entryDate, diaryEntry, userName) {
var options = {};
options["date"] = entryDate;
options["entry"] = diaryEntry;
$.ajax({
url: 'http://127.0.0.1:8082/'+userName+'/diary',
type: 'POST',
data: JSON.stringify(options),
contentType: 'application/json',
success: function (data) {
console.log("Successfully posted entry");
},
error: function (data) {
console.error('Unable to post entry');
}
});
}
var readEntry = function(entryDate, userName) {
var options = {};
options["date"] = entryDate;
$.ajax({
url: 'http://127.0.0.1:8082/'+userName+'/diary',
type: 'GET',
data: JSON.stringify(options),
contentType: 'application/json',
success: function (data) {
console.log("Successfully retrieved entry");
$(".entry").val(data);
},
error: function (data) {
console.log(data);
console.error('Unable to retrieve entry');
}
});
}