1

I have button on checkout page. When I clicked on that button, an ajax event it is called and returns me a HTML code, which is actually the html code from the next step(payments step). I want to add some CSS code after the ajax event. How can I do that? I tried, by using the ajaxComplete function, but its not firing.

 jQuery(document).ready(function(){ 
 jQuery(document).ajaxError(function(e, jqxhr, settings, exception) {
 alert(exception);
 })
 })

or

jQuery('body').ajaxComplete(function(event, xhr, settings ) {
 alert(settings.url);
 });

or prototype:

new Ajax.Request('<?php echo $this->getUrl('checkout/onepage/saveBilling') ?>', {
 onComplete: function(response) {
 if (200 == response.status)
 alert(01);
 }
 });

Neither of them are not working! any idea why ? UPDATE This is part of the code from opcheckout.js

save: function(){
 if (checkout.loadWaiting!=false) return;
 var validator = new Validation(this.form);
 if (this.validate() && validator.validate()) {
 checkout.setLoadWaiting('payment');
 var request = new Ajax.Request(
 this.saveUrl,
 {
 method:'post',
 onComplete: this.onComplete,
 onSuccess: this.onSave,
 onFailure: checkout.ajaxFailure.bind(checkout),
 parameters: Form.serialize(this.form)
 }
 );
 }
 },

Where can i add a condition after onComplete?

asked Aug 25, 2015 at 8:27

1 Answer 1

1

You should be able to wrap the onComplete method to add your CSS.

Billing.prototype.save = Billing.prototype.save.wrap(function(parentMethod){
 // call the parent so normale behavior is executed 
 parentMethod();
 alert("Put your CSS here");
});
answered Sep 2, 2015 at 9:55
2
  • 1
    How can i detect in Shipping Address Page? Commented Feb 27, 2020 at 14:01
  • Or Shipping Method ? Commented Jan 7, 2021 at 14:48

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.