Ajax front-end user registration form - not returning JSON
EDIT

Craft 2.4 is now available, and the users/saveUser action will now return a JSON response for AJAX requests.

The original answer is still valid for &lt;2.4 builds:

No, there's no way to trigger a JSON response for the users/saveUser action.

Other UsersController actions (such as users/login do return JSON for AJAX requests, so it might be an idea to submit this as a feature request – as a consistency measure, if nothing else.

For now, here's a couple of ideas for workarounds:


Write a plugin with a controller that wraps the UsersController-&gt;actionSaveUser() method somehow, or implements its own action (you could basically just copy paste the whole actionSaveUser() from the core UsersController, changing it to return some JSON at the end).
You can set the redirect parameter (using a hidden input field in your form) to point to a template where you build the JSON yourself.


Form:

&lt;form method="post" action="" id="register-form" accept-charset="UTF-8"&gt;
     &lt;!-- Your form code --&gt;
     &lt;input type="hidden" name="redirect" value="{{ url( 'path/to/your/template/or/a/route' }}"&gt;
&lt;/form&gt;


Template for the redirect (notice the JSON header):

{% header "Content-Type: application/json" %}
{
    "success" : {{ account is defined and account.id ? true : false }}
}