Subversion Repositories SmartDukaan

Rev

Rev 23343 | Rev 23377 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 23343 Rev 23347
Line 1... Line -...
1
 
-
 
2
function badRequestAlert(response){
1
function badRequestAlert(response){
3
	console.log(response.responseText);
2
	console.log(response.responseText);
4
	var errorObject = JSON.parse(response.responseText);
3
	var errorObject = JSON.parse(response.responseText);
5
	errorObject = errorObject.response;
4
	errorObject = errorObject.response;
6
	alert('Bad Request\n'+
5
	alert('Bad Request\n'+
7
			'rejectedType : '+errorObject.rejectedType+'\n'+
6
			'rejectedType : '+errorObject.rejectedType+'\n'+
8
			'rejectedValue : '+errorObject.rejectedValue+'\n'+
7
			'rejectedValue : '+errorObject.rejectedValue+'\n'+
9
			'message : '+errorObject.message);
8
			'message : '+errorObject.message);
10
}
9
}
11
 
10
	
12
function internalServerErrorAlert(response){
11
function internalServerErrorAlert(response){
13
	console.log(response.responseText);
12
	console.log(response.responseText);
14
	var errorObject = JSON.parse(response.responseText);
13
	var errorObject = JSON.parse(response.responseText);
15
	errorObject = errorObject.response;
14
	errorObject = errorObject.response;
16
	alert('Internal Server Error\n'+
15
	alert('Internal Server Error\n'+
Line 36... Line 35...
36
	   async: true,
35
	   async: true,
37
	   cache: false,
36
	   cache: false,
38
	   data: params,
37
	   data: params,
39
       //dataType:'json',
38
       //dataType:'json',
40
	   type: httpType,
39
	   type: httpType,
41
	   /*beforeSend: function(){
-
 
42
		    $(".loading").show();
-
 
43
	   },*/
-
 
44
	   success: function(response) {
40
	   success: function(response) {
45
	      //console.log("response"+JSON.stringify(data));
41
	      //console.log("response"+JSON.stringify(data));
46
	      callback_function(response);
42
	      callback_function(response);
47
	      //$(".loading").hide();
-
 
48
	   }
43
	   }
49
	});
44
	});
50
}
45
}
51
 
46
 
52
function doAjaxRequestWithJsonHandler(urlString, httpType, json, callback_function){
47
function doAjaxRequestWithJsonHandler(urlString, httpType, json, callback_function){
Line 56... Line 51...
56
	   cache: false,
51
	   cache: false,
57
	   processData: false,
52
	   processData: false,
58
	   data: json,
53
	   data: json,
59
       contentType:'application/json',
54
       contentType:'application/json',
60
	   type: httpType,
55
	   type: httpType,
61
	   /*beforeSend: function(){
-
 
62
	    	$(".loading").show();
-
 
63
  		},*/
-
 
64
	   success: function(response) {
56
	   success: function(response) {
65
	      //console.log("response"+JSON.stringify(data));
57
	      //console.log("response"+JSON.stringify(data));
66
	      callback_function(response);
58
	      callback_function(response);
67
	      //$(".loading").hide();
-
 
68
	   }
59
	   }
69
	});
60
	});
70
}
61
}
71
 
62
 
72
 
63
 
Line 74... Line 65...
74
	$.ajax({
65
	$.ajax({
75
	   url: urlString,
66
	   url: urlString,
76
	   async: true,
67
	   async: true,
77
	   cache: false,
68
	   cache: false,
78
	   type: httpType,
69
	   type: httpType,
79
	   /*beforeSend: function(){
-
 
80
	    	$(".loading").show();
-
 
81
  		},*/
-
 
82
	   success: function(response) {
70
	   success: function(response) {
83
	      //console.log("response"+JSON.stringify(data));
71
	      //console.log("response"+JSON.stringify(data));
84
	      callback_function(response);
72
	      callback_function(response);
85
	      //$(".loading").hide();
-
 
86
	   }
73
	   }
87
	});
74
	});
88
}
75
}
89
 
76
 
-
 
77
function doAjaxUploadRequest(urlString, httpType, file){
-
 
78
	var response;
-
 
79
	doAjaxUploadRequestHandler(urlString, httpType, file, function(ajaxResponse){
-
 
80
		response = ajaxResponse;
-
 
81
	});
-
 
82
	return response;
-
 
83
}
-
 
84
 
90
function doAjaxUploadRequestHandler(urlString, httpType, file, callback_function){
85
function doAjaxUploadRequestHandler(urlString, httpType, file, callback_function){
91
	var formData = new FormData();
86
	var formData = new FormData();
92
	formData.append("file", file);
87
	formData.append("file", file);
93
	$.ajax({
88
	$.ajax({
94
	   url: urlString,
89
	   url: urlString,
Line 98... Line 93...
98
       async: true,
93
       async: true,
99
       cache: false,
94
       cache: false,
100
       contentType: false,
95
       contentType: false,
101
       enctype: 'multipart/form-data',
96
       enctype: 'multipart/form-data',
102
       processData: false,
97
       processData: false,
103
       /*beforeSend: function(){
-
 
104
	    	$(".loading").show();
-
 
105
  		},*/
-
 
106
	   success: function(response) {
98
	   success: function(response) {
107
	      //console.log("response"+JSON.stringify(data));
99
	      //console.log("response"+JSON.stringify(data));
108
	      callback_function(response);
100
	      callback_function(response);
109
	      //$(".loading").hide();
-
 
110
	   }
101
	   }
111
	});
102
	});
112
}
103
}
113
 
104
 
-
 
105
function uploadDocument(file){
-
 
106
	var url = '/profitmandi-web/document-upload';
-
 
107
	var response = doAjaxUploadRequest(url, 'POST', file);
-
 
108
	var documentId = response.response.document_id; 
-
 
109
	console.log("documentId : "+documentId);
-
 
110
	return documentId;
-
 
111
}
-
 
112
 
114
function doAjaxGetDownload(urlString, fileName){
113
function doAjaxGetDownload(urlString, httpType, fileName){
115
	doAjaxDownload(urlString, "GET", null, fileName);
114
	doAjaxDownload(urlString, "GET", null, fileName);
116
}
115
}
117
 
116
 
118
function doAjaxPostDownload(urlString, data, fileName){
117
function doAjaxPostDownload(urlString, httpType, data, fileName){
119
	doAjaxDownload(urlString, "POST", data, fileName);
118
	doAjaxDownload(urlString, "POST", data, fileName);
120
}
119
}
121
 
120
 
122
function doAjaxDownload(urlString, httpType, data, fileName){
121
function doAjaxDownload(urlString, httpType, data, fileName){
123
	xhttp = new XMLHttpRequest();
122
	xhttp = new XMLHttpRequest();
Line 146... Line 145...
146
		xhttp.setRequestHeader("Content-Type", "application/json");
145
		xhttp.setRequestHeader("Content-Type", "application/json");
147
	}
146
	}
148
	// You should set responseType as blob for binary responses
147
	// You should set responseType as blob for binary responses
149
	xhttp.responseType = 'blob';
148
	xhttp.responseType = 'blob';
150
	xhttp.send(data);
149
	xhttp.send(data);
151
}
150
}
152
 
-
 
153
function downloadReport(urlString, httpType, data, fileName){
-
 
154
	
-
 
155
}
-
 
156
 
-
 
157
function uploadDocument(file){
-
 
158
	var url = '/profitmandi-web/document-upload';
-
 
159
	doAjaxUploadRequestHandler(url, 'POST', file, function(response){
-
 
160
		var documentId = response.response.document_id; 
-
 
161
		console.log("documentId : "+documentId);
-
 
162
		return documentId;
-
 
163
	});
-
 
164
}
-
 
165
151