Skip to content

Commit 0b815b5

Browse files
response handler add
1 parent e792a8d commit 0b815b5

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "LightPivotTable",
33
"author": "ZitRo",
4-
"version": "1.0.0-beta.18",
4+
"version": "1.0.0-beta.19",
55
"description": "A lightweight pivot table for MDX2JSON source for InterSystems Cache",
66
"main": "test/testServer.js",
77
"repository": {

readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ var setup = { // Object that contain settings. Properties in brackets can be mis
5353
, back: function ({Object { level: {number} }}) {}
5454
// if cellDrillThrough callback returns boolean false, DrillThrough won't be performed.
5555
, cellDrillThrough: function ({Object { event: {event}, filters: {string[]}, cellData: {object} }}) {}
56+
, responseHandler: function ({Object {url: {string}, status: {number}}}) {}
5657
} ]
5758
[ , pagination: 30 ] // Maximum rows number on one page (default: 200, turn off: 0)
5859
[ , hideButtons: true ] // hides "back" and "drillThrough" buttons

source/js/DataSource.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,21 @@ var DataSource = function (config, globalConfig, lpt) {
3939
* @private
4040
*/
4141
DataSource.prototype._post = function (url, data, callback) {
42-
var xhr = new XMLHttpRequest();
42+
var xhr = new XMLHttpRequest(),
43+
self = this;
4344
xhr.open("POST", url);
4445
if (this.SEND_COOKIES) xhr.withCredentials = true;
4546
xhr.onreadystatechange = function () {
47+
var handler;
48+
if (xhr.readyState === 4) {
49+
handler = self.LPT.CONFIG.triggers["responseHandler"];
50+
if (typeof handler === "function") {
51+
handler.call(self.LPT, {
52+
url: url,
53+
status: xhr.status
54+
});
55+
}
56+
}
4657
if (xhr.readyState === 4 && xhr.status === 200) {
4758
callback((function () {
4859
try {

0 commit comments

Comments
 (0)