forked from Asiatik/codezilla
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingleton.js
More file actions
60 lines (54 loc) · 1.94 KB
/
Copy pathsingleton.js
File metadata and controls
60 lines (54 loc) · 1.94 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
(function ($) {
$.CreateSingleton = function (p) {
var Singleton = {
config: {
isPostBack: false,
async: false,
cache: false,
type: 'POST',
contentType: "application/json; charset=utf-8",
data: { data: '' },
dataType: 'json',
baseURL: "Web Service url",
method: "",
ajaxCallMode: 0,
successMethod: "",
failureMethod: ""
},
init: function () {
},
ajaxCall: function () {
$.ajax({
type: Singleton.config.type,
contentType: Singleton.config.contentType,
cache: Singleton.config.cache,
url: Singleton.config.baseURL + Singleton.config.method,
data: Singleton.config.data,
dataType: Singleton.config.dataType,
success: Singleton.config.successMethod,
error: Singleton.config.failureMethod,
async: Singleton.config.async
});
},
invokeAjax: function(){
cat.config.method = "method";
cat.config.data = JSON.stringify({
param1: value1
});
cat.config.successMethod = cat.invokeAjaxSuccess;
cat.config.failureMethod = cat.invokeAjaxFailure;
cat.ajaxCall(cat.config);
},
invokeAjaxSuccess: function(data){
console.log(data.d);
},
invokeAjaxFailure: function(){
console.log("Something went wrong.", "error");
}
};
Singleton.init();
};
$.fn.CallSingleton = function (p) {
$.CreateSingleton(p);
};
})(jQuery);