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:

function formulaires_nom_traiter(){
	// Prevent AJAX processing since we know that the form will redirect elsewhere
	refuser_traiter_formulaire_ajax();
	
	// Execute the processes
	
	// Return values
	return array(
		'redirect' => 'Another URL'
	);
}

Author Mark Baber Published : Updated : 12/03/23

Translations : English, français