Skip to content

Commit

Permalink
Merge pull request #43 from usernane/usernane-patch-1
Browse files Browse the repository at this point in the history
Fix to a Bug in Binding
  • Loading branch information
usernane authored Jul 19, 2023
2 parents 3ef55d5 + 496190c commit cc1a751
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 18 deletions.
21 changes: 11 additions & 10 deletions AJAXRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,12 +92,12 @@ Object.defineProperties(AJAXRequest, {
});

Object.defineProperties(AJAXRequest.META, {
ERSION: {
value: '2.1.8',
VERSION: {
value: '2.1.9',
writable: false
},
REALSE_DATE: {
value: '2023-07-09',
value: '2023-07-19',
writable: false
},
CONTRIBUTORS: {
Expand Down Expand Up @@ -393,7 +393,7 @@ function AJAXRequest(config = {

for (var i = 0; i < inst.onerrorpool.length; i++) {
try {

bindParams(inst.onerrorpool[i], inst);
if (canCall(inst.onerrorpool[i])) {
inst.log('AJAXRequest: Callback ' + inst.onerrorpool[i].id + ' is enabled.', 'info');
inst.onerrorpool[i].AJAXRequest = inst;
Expand All @@ -403,7 +403,7 @@ function AJAXRequest(config = {
inst.onerrorpool[i].xmlResponse = inst.responseXML;
inst.onerrorpool[i].jsonResponse = jsonResponse;
inst.onerrorpool[i].responseHeaders = headers;
bindParams(inst.onerrorpool[i], inst);

inst.onerrorpool[i].func();
} else {
inst.log('AJAXRequest: Callback "' + inst.onerrorpool[i].id + '" is disabled.', 'warning');
Expand Down Expand Up @@ -437,10 +437,9 @@ function AJAXRequest(config = {
xhr[p][i].responseHeaders = getResponseHeadersObj(xhr);

try {

bindParams(xhr[p][i], xhr.AJAXRequest);
if (canCall(xhr[p][i])) {
xhr.log('AJAXRequest: Callback "' + xhr[p][i].id + '" is enabled.', 'info');
bindParams(xhr[p][i], xhr.AJAXRequest);
xhr[p][i].func();
} else {
xhr.log('AJAXRequest: Callback "' + xhr[p][i].id + '" is disabled.', 'warning');
Expand All @@ -459,10 +458,10 @@ function AJAXRequest(config = {
xhr.onafterajaxpool[i].responseHeaders = headers;

try {

bindParams(xhr.onafterajaxpool[i], xhr.AJAXRequest);
if (canCall(xhr.onafterajaxpool[i])) {
xhr.log('AJAXRequest: Callback "' + xhr.onafterajaxpool[i].id + '" is enabled.', 'info');
bindParams(xhr.onafterajaxpool[i], xhr.AJAXRequest);

xhr.onafterajaxpool[i].func();
} else {
xhr.log('AJAXRequest: Callback "' + xhr.onafterajaxpool[i].id + '" is disabled.', 'warning');
Expand Down Expand Up @@ -1448,8 +1447,10 @@ function AJAXRequest(config = {
this.log('AJAXRequest.send: Executing before AJAX callbacks...', 'info');
for (var i = 0; i < this.onbeforeajaxpool.length; i++) {
try {
bindParams(this.onbeforeajaxpool[i], this);

if (canCall(this.onbeforeajaxpool[i])) {
bindParams(this.onbeforeajaxpool[i], this);

this.onbeforeajaxpool[i].func();
}
} catch (e) {
Expand Down
18 changes: 10 additions & 8 deletions dist/AJAXRequest.min.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Object.defineProperties(AJAXRequest, {

Object.defineProperties(AJAXRequest.META, {
VERSION: {
value: '2.1.8',
value: '2.1.9',
writable: false
},
REALSE_DATE: {
Expand Down Expand Up @@ -373,7 +373,8 @@ function AJAXRequest(config = {

for (var i = 0; i < inst.onerrorpool.length; i++) {
try {

bindParams(inst.onerrorpool[i], inst);

if (canCall(inst.onerrorpool[i])) {
inst.onerrorpool[i].AJAXRequest = inst;
inst.onerrorpool[i].e = e;
Expand All @@ -382,7 +383,7 @@ function AJAXRequest(config = {
inst.onerrorpool[i].xmlResponse = inst.responseXML;
inst.onerrorpool[i].jsonResponse = jsonResponse;
inst.onerrorpool[i].responseHeaders = headers;
bindParams(inst.onerrorpool[i], inst);

inst.onerrorpool[i].func();
}
} catch (e) {
Expand Down Expand Up @@ -412,9 +413,9 @@ function AJAXRequest(config = {
xhr[p][i].responseHeaders = getResponseHeadersObj(xhr);

try {

bindParams(xhr[p][i], xhr.AJAXRequest);
if (canCall(xhr[p][i])) {
bindParams(xhr[p][i], xhr.AJAXRequest);

xhr[p][i].func();
}
} catch (e) {
Expand All @@ -431,9 +432,9 @@ function AJAXRequest(config = {
xhr.onafterajaxpool[i].responseHeaders = headers;

try {

bindParams(xhr.onafterajaxpool[i], xhr.AJAXRequest);
if (canCall(xhr.onafterajaxpool[i])) {
bindParams(xhr.onafterajaxpool[i], xhr.AJAXRequest);

xhr.onafterajaxpool[i].func();
}
} catch (e) {
Expand Down Expand Up @@ -1330,8 +1331,9 @@ function AJAXRequest(config = {
value: function () {
for (var i = 0; i < this.onbeforeajaxpool.length; i++) {
try {
bindParams(this.onbeforeajaxpool[i], this);
if (canCall(this.onbeforeajaxpool[i])) {
bindParams(this.onbeforeajaxpool[i], this);

this.onbeforeajaxpool[i].func();
}
} catch (e) {
Expand Down

0 comments on commit cc1a751

Please sign in to comment.