Navigation überspringen

[Gelöst] jQuery after AJAX form submit

This support ticket is created vor 8 Monaten, 1 Woche. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Zeitzone des Unterstützers: Asia/Kolkata (GMT+05:30)

Dieses Thema enthält 3 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von Minesh vor 8 Monaten, 1 Woche.

Assistiert von: Minesh.

Author
Artikel
#2778296

Hi, I need to use jQuery after AJAX form submit. I tried these snipets:

jQuery(document).ajaxComplete(function (event, xhr, settings) {
   
    if(settings.hasOwnProperty('extraData')){
        console.log('test1);
    }
     
});

jQuery( document ).ajaxComplete(function() { 
        console.log('test2);
});

jQuery(document).on('cred_form_ready', function(){
        console.log('test3);
});

None of them worked for me.

How can I run my on.click function after the form is submited with AJAX?

cheers

#2778308

I found the solution. I was loading the form inside [wpv-no-items-found]...[/wpv-no-items-found] shortcodes. These was breaking AJAX/JS. I put the form outside and now 'ajaxComplete' works fine.

cheers

#2778309

Minesh
Unterstützer

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - here is a sandbox site and you can auto-login to it using the following link:
- versteckter Link

The following form is set to submit with AJAX:
=> versteckter Link

The form is added the following page:
- versteckter Link

As you can see there is a link "CLICK HERE" at top of the above test form page and if you click on this link it will show you alert with message "hi there" - that is added as given under with the above form:
=> => versteckter Link

<a href="#" id="anchor_click" onclick="javascript:alert('hi there');"> CLICK HERE </a>

I've added the following custom JS code to the form's custom JS editor that should run the click event automatically on form submit, so when you submit the form it should automatically show the alert "hi there":
=> => versteckter Link

jQuery( document ).ready(function($) {
  

  jQuery(document).ajaxComplete(function (event, xhr, settings) {
   
    if(settings.hasOwnProperty('extraData')){
        jQuery("#anchor_click").trigger('click');
    }
     
});
});

Now, when I submit the form and I see it does trigger the click event.
- versteckter Link

You can adjust the code as required.

#2778318

Minesh
Unterstützer

Sprachen: Englisch (English )

Zeitzone: Asia/Kolkata (GMT+05:30)

It seems we have cross-posted. You can mark this as resolved with different message.