-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRestService.js
More file actions
73 lines (67 loc) · 1.95 KB
/
RestService.js
File metadata and controls
73 lines (67 loc) · 1.95 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
function RestServiceJs(newurl) {
this.myurl = newurl;
this.add = function(model, callback) {
$.ajax({
type: 'POST',
url: this.myurl,
data: JSON.stringify(model), // '{"name":"' + model.name + '"}',
dataType: 'text',
processData: false,
contentType: 'application/json',
success: callback,
error: function(req, status, ex) {},
timeout:60000
});
};
this.update = function(model, callback) {
$.ajax({
type: 'PUT',
url: this.myurl,
data: JSON.stringify(model), // '{"name":"' + model.name + '"}',
dataType: 'text',
processData: false,
contentType: 'application/json',
success: callback,
error: function(req, status, ex) {},
timeout:60000
});
};
this.find = function(id, callback) {
$.ajax({
type: 'GET',
url: this.myurl + '/' + id,
contentType: 'application/json',
success: callback,
error: function(req, status, ex) {},
timeout:60000
});
};
this.findAll = function(callback) {
$.ajax({
type: 'GET',
url: this.myurl,
contentType: 'application/json',
success: callback,
error: function(req, status, ex) {},
timeout:60000
});
};
this.remove = function(id, callback) {
$.ajax({
type: 'DELETE',
url: this.myurl + '/' + id,
contentType: 'application/json',
success: callback,
error: function(req, status, ex) {},
timeout:60000
});
};
this.loadTmpl = function(turl, callback) {
$.ajax({
url: turl,
success: callback,
error: function(req, status, ex) {},
timeout:60000
});
}
}