AJAX functionality...
When I bought the suite a few months ago, support reassured me that AJAX requests could be handled. I have determined that this is not the case unfortunately. However, I was determined to find a solution.
I have been testing a simple solution for a few months that works beautifully; and it does not in any way impact current functions.
The problem:
Jquery/javascript sends an Xhr (AJAX) request to ’webassist authenticate user’ script, the script will exit when either ‘success’ or ‘failure’ parameters are set and redirect using: header("Location:…”) (a new url).
A solution:
By using a convention for the ‘success’ or ‘failure’ parameters…I can say ‘if parameter begins with ‘ajax_’ then treat it as an AJAX request, and simply echo the parameter'. The client side script would then get the request response and handle it appropriately. Example parameters: ajax_authenticationSuccess and ajax_authenticationFail.
If parameter does not begin with ‘ajax_’ then redirect as usual.
In helper_php.php it is easy to wrap the redirect with an if/else statement like this:
if (preg_match('/^ajax_/i', $WA_Auth_Parameter["successRedirect"])) {
echo $WA_Auth_Parameter["successRedirect"];
} else {
header("Location: ".$WA_Auth_Parameter["successRedirect"]); //webassist original line
}
exit();
To add this to the widgets, (instead of using ‘ajax_’), you could simply add a checkbox labeled ‘AJAX’ for each input/redirect field (a checkbox for each is good as I have sometimes mixed AJAX and Header redirects in a single script).
This would be nice to have baked into every widgets that does redirects.
And the best thing is that it would not have any impact on legacy code, etc.
Brent