Adding Callback Function To Default Ajax Call

Hello,

I want to add a callback function to the default ajax call, is it possible? If yes, how can i implement it? please suggest me.

Thanks in advance!

If you write your own request, please check the bottom part of the following article:

http://docs.cs-cart.com/4.3.x/developer_guide/core/coding_standards/jquery.html

If you need callbacks for forms, please check the Form processing section here:

http://docs.cs-cart.com/4.3.x/developer_guide/core/front-end/microformats.html

If you write your own request, please check the bottom part of the following article:

http://docs.cs-cart.com/4.3.x/developer_guide/core/coding_standards/jquery.html

If you need callbacks for forms, please check the Form processing section here:

http://docs.cs-cart.com/4.3.x/developer_guide/core/front-end/microformats.html

hi,

This is helpful but my problem is different. There are payment tabs at checkout page, on click there is an ajax call, actually i want to add a callback function to that. I tried to find out from where this ajax is called, but not succeeded. Is there any way to implement it?

design/themes/YOUR_THEME/templates/views/checkout/components/payments/payment_methods.tpl

The ajax is called by the following code:

{__($tab_name)}

In your case it is required to rewrite the code and use method #1 from my post to make ajax call and add callback function

design/themes/YOUR_THEME/templates/views/checkout/components/payments/payment_methods.tpl

The ajax is called by the following code:

{__($tab_name)}

In your case it is required to rewrite the code and use method #1 from my post to make ajax call and add callback function

hello eComLabs,

We can use this also,

$.ceEvent('on', 'ce.ajaxdone', function(e){

//code

});

I think this is the easiest way to do it. right?

hello eComLabs,

We can use this also,

$.ceEvent('on', 'ce.ajaxdone', function(e){

//code

});

I think this is the easiest way to do it. right?

You are right! I forgot about this trigger, sorry

You are right! I forgot about this trigger, sorry

Yeah, But we can not use this trigger always, because it triggers for all the ajax calls occuring on the particular page. to enable callback function for a particular ajax we should use method #1 from your post. ;)

Yeah, But we can not use this trigger always, because it triggers for all the ajax calls occuring on the particular page. to enable callback function for a particular ajax we should use method #1 from your post. ;)

You can always check event properties (e.g. selector). E.g.

$.ceEvent('on', 'ce.ajaxdone', function(e){
    for (i = 0; i < e.length; i++) {
        alert(e[i].selector);
    }
});

You can always check event properties (e.g. selector). E.g.

$.ceEvent('on', 'ce.ajaxdone', function(e){
    for (i = 0; i < e.length; i++) {
        alert(e[i].selector);
    }
});

I guess e[i].selector is reflecting result_ids. But if in case we need to fetch the element triggering the ajax, is there any way to fetch that element?

I guess e[i].selector is reflecting result_ids. But if in case we need to fetch the element triggering the ajax, is there any way to fetch that element?

Use

console.log(e);

to check the events content in the developers console of your browser

Use

console.log(e);

to check the events content in the developers console of your browser

Thanks for this, but there is the function consturctor:function(e,t) which holds the lastElementClicked. I can view it only in console but don't know how to access it. Is there any way to access it? It will be really appreciating if you help me to find the way to access the function.

Thanks for this, but there is the function consturctor:function(e,t) which holds the lastElementClicked. I can view it only in console but don't know how to access it. Is there any way to access it? It will be really appreciating if you help me to find the way to access the function.

Unfortunately, we have not find an easy way to access this property. More detailed examination is required