Processing without AJAX

If a form is called using AJAX but then redirects to another page after finishing its processes, this would require Javascript tricks (managed by SPIP) to capture that redirection and effectively send the browser to another URL instead of the normal response.

Whenever a redirection is certain, it is possible to prevent AJAX for the form’s processing, while still maintaining it for the verification phase. This means that the form would be reloaded in the event of an error in verifier(), but if the processing is executed, then the whole page will be immediately reloaded.

To do this, you must call the refuser_traiter_formulaire_ajax()function right at the start of the processes:

  1. function formulaires_nom_traiter(){
  2. // Prevent AJAX processing since we know that the form will redirect elsewhere
  3. refuser_traiter_formulaire_ajax();
  5. // Execute the processes
  7. // Return values
  8. return array(
  9. 'redirect' => 'Another URL'
  10. );
  11. }


Author Mark Baber Published :

Translations : English, français