# File lib/cgikit/ajax/handler.rb, line 98
    def handle_request( request )
      super
      action, name = action_and_action_name(request)

      result = nil
      @application.synchronize do
        result = action.perform_action(name)
        if result.respond_to?(:generate_response) then
          response = result.generate_response
          if Component === result then
            response.component = result
            if result.context.has_session? then
              @application.save_session(result.context)
            end
          end
        else
          response = Response.new
          if result.nil? or Array === result or Hash === result then
            response.content = XMLSerializer.serialize(result)
          elsif ::String === result then
            response.content = result
          else
            raise ActionResultError, \
            "Ajax action must return an object has generate_response(), " +
              "not nil, String, Array or Hash. - #{action.class}##{action_name}"
          end
        end
      end

      response.headers['Content-Type'] = 'text/xml'
      response
    end