<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def form_invalid(self, form):
 """ We have errors in the form. If ajax, return them as json. Otherwise, proceed as normal. """

        if self.request.is_ajax():
            return self.render_json_response(self.get_error_result(form))
        return super(AjaxFormMixin, self).form_invalid(form)