Skip to content

Instantly share code, notes, and snippets.

@mzur

mzur/contact-send.php

Last active Sep 11, 2015
Embed
What would you like to do?
Old version of the AJAX response template (http://blog.the-inspired-ones.de/ajax-uniform)
<?php
header::contentType('application/json');
$errors = '';
// check each parameter of the request if it is erroneous
foreach (array_keys(get()) as $field) {
$errors .= $form->hasError($field) ? "\"$field\"," : '';
}
// strip trailing comma
$errors = substr($errors, 0, -1);
?>
{
"success": <?php e($form->successful(), 'true', 'false')?>,
"message": "<?php echo trim($form->message()) ?>",
"errors": [<?php echo $errors ?>]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.