Skip to content

Commit 8b67036

Browse files
committed
[improve] Replace ajax "done" function with success & error arguments
1 parent 425de02 commit 8b67036

1 file changed

Lines changed: 24 additions & 17 deletions

File tree

upload_ce_phoenix/includes/javascript/paylike.js

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,25 @@ function pay(args, checkout, form) {
2424
data: {
2525
action: 'setTransactionId',
2626
id: r.transaction.id
27-
}
28-
}).done(function(r) {
29-
if (r.err) {
30-
return 0;
31-
}
32-
if (checkout) {
33-
checkout.checkAllErrors();
34-
} else {
35-
/* Remove form submit event which prevent form action to proceed */
36-
/* Set form action attribute */
37-
/* Force submit form */
38-
$(form).off('submit', submitForm).attr("action", $(form).find("#payLikeCheckout").attr("action")).submit();
27+
},
28+
error: function(jqXHR, textStatus, errorThrown) {
29+
if (errorThrown) {
30+
console.error(errorThrown);
31+
return 0;
32+
}
33+
},
34+
success: function(data, textStatus, jqXH) {
35+
if (checkout) {
36+
checkout.checkAllErrors();
37+
} else {
38+
/* Remove form submit event which prevent form action to proceed */
39+
/* Set form action attribute */
40+
/* Force submit form */
41+
$(form).off('submit', submitForm).attr("action", $(form).find("#payLikeCheckout").attr("action")).submit();
42+
}
3943
}
4044
})
45+
4146
return false;
4247
});
4348
}
@@ -57,12 +62,14 @@ function submitForm(e) {
5762
url: orderDataPath,
5863
data: {
5964
action: 'getOrderTotalsData'
65+
},
66+
error: function(jqXHR, textStatus, errorThrown) {
67+
console.error(errorThrown);
68+
},
69+
success: function(data, textStatus, jqXHR) {
70+
var checkoutObj = (typeof checkout === 'undefined') ? (false) : (checkout);
71+
pay(data, checkoutObj, form);
6072
}
61-
}).done(function(r) {
62-
var checkoutObj = typeof checkout === 'undefined'
63-
? false
64-
: checkout;
65-
pay(r, checkoutObj, form);
6673
})
6774
/* Prevent form action to proceed */
6875
e.preventDefault(e);

0 commit comments

Comments
 (0)