Ajax Form Submit


New Member
Hello All, I've been jumping back into MailWizz over the past week after a long while. Today, my server hosting MW, had a hiccup (DB froze and required a server restart). The VPS has been online for several years without a hiccup but there were a lot of email signups today on top of recently updating to the current version of MW which may have contributed. So people (me included when I discovered the problem with the server) would submit the form and then go to a page with a DB error (no fault of MW - just that the server was in a bind). MW is hosted on a server other than the form.

At any rate, I can't afford downtime or slowtime if MW or the MW server becomes unresponsive. I'd rather lose the potential contacts and have them still get to the next page. I've been looking at alternate ways of bypassing the MW submit in case there is a problem. I was using ConvertKit which had a Javascript that would force the redirect to the "thanks" page.

I found some ideas on StackExchange and then Google lead me to https://github.com/twisted1919/mailwizz-php-sdk/blob/master/examples/ajax_subscribe.php
I started working on this but it's a grade above my know how and I still can't see a way in any of the examples to say "hey, the MW server isn't responding... let's skip it and go to the thanks page". I searched the forum here, but it doesn't seem to be a popular topic.

Does anyone know of a workaround to bypass the submit if there is any problem resolving the MW server (server down, DB locked, network errors or whatever)? I'm sure there is some Javascript, Ajax or something maybe even more simple that would work but I just haven't found it yet. Thanks for any ideas.
@Stratagem - Why not use the api like you do now, but use a smaller timeout value so that you don't have to wait that long for the request to continue, you'd basically edit the file https://github.com/twisted1919/mailwizz-php-sdk/blob/master/MailWizzApi/Http/Client.php#L79 and at line 79, put a 5 seconds timeout. Then put the api call in a try{}catch(){} block, smth like:
try {

  $response = $endpoint->create('LIST-UNIQUE-ID', array(
    'EMAIL' => 'john.doe@doe.com', // the confirmation email will be sent!!! Use valid email address
    'FNAME' => 'John',
    'LNAME' => 'Doe'

} catch (Exception $e) {}
This way, if after 5 seconds things won't work out, the execution of the script will continue ;)