Generate the ajax response.

@return Response
188267
public function generateResponse()
    {
        $data = $this->getData();

        if ($data instanceof \Closure) {
            $data = $data();
        }

        $encoders = [new XmlEncoder(), new JsonEncoder()];
        $normalizers = [new GetSetMethodNormalizer()];
        $serializer = new Serializer($normalizers, $encoders);

        $response = new Response();
        $response->headers->set('Content-Type', 'application/'.$this->getFormat());
        $response->setContent($serializer->serialize($data, $this->getFormat()));

        return $response;
    }
711164
public function render()
    {
        // Set the request arguments as GET parameters
        $_GET = $this->getRequestArguments();

        try {
            /** @var \TYPO3\CMS\Extbase\Mvc\Web\Response $response */
            $response = $this->objectManager->get(Response::class);
            $this->request->setOriginalRequestMappingResults($this->validationErrors);
            $this->getControllerInstance()->processRequest($this->request, $response);
            $result = $this->beautify($response->getContent());

            // In case of an error
        } catch (\Exception $e) {
            $result = '<pre class="error"><strong>'.$e->getMessage().'</strong>'.PHP_EOL
                      .$e->getTraceAsString().'</pre>';
        }

        return $result;
    }
652328
public function generateAction()
    {
        $extension  = $this->params()->fromRoute('extension', QrCodeServiceInterface::DEFAULT_EXTENSION);
        $content    = $this->qrCodeService->getQrCodeContent($this->params());
        return $this->createResponse($content, $this->qrCodeService->generateContentType($extension));
    }
791551
protected function ajaxResponseHandler()
    {
        echo json_encode([
            'success'      => $this->errorMessage ? 0 : 1,
            'errorMessage' => $this->errorMessage,
            'errorCode'    => $this->errorCode,
            'data'         => $this->errorMessage ? '' : $this->dataPacket,
        ]);

        die();
    }
18050
public function respond()
    {
        $response = array();

        foreach ($this->queue as $object) {
            $response[] = $object->render();
        }

        return array('ajaxcom' => $response);
    }
1240773
public function toResponse(): Response
    {
        return new Response(
            $this->status,
            $this->headers,
            $this->body,
            $this->httpVersion,
            $this->reason
        );
    }
643877
public function dashboardAction(): Response
    {
        $editForm = $this->formFactory->contentEdit(
            new ContentEditData()
        );

        return $this->render('@ezdesign/dashboard/dashboard.html.twig', [
            'form_edit' => $editForm->createView(),
            'can_create_content' => $this->permissionResolver->hasAccess('content', 'create'),
        ]);
    }
416135
public function ajax()
    {
        return datatables($this->query())
            ->setTransformer(app($this->transformer))
            ->orderColumn('title', 'title->"$.'.app()->getLocale().'" $1')
            ->make(true);
    }
298106
public function preparePaginationResponse()
    {
        return new Response($this->total, $this->perPage, $this->page, $this->lastPage);
    }
652856
public function handle()
    {
        if (! $this->is_ajax_request()) {
            return Handler::DONE;
        }

        $response = [
            'success' => false,
            'data'    => Formatter::formatExceptionAsDataArray($this->getInspector(), $this->addTraceToOutput()),
        ];

        if (Misc::canSendHeaders()) {
            \header('Content-Type: application/json; charset=' . get_option('blog_charset'));
        }

        echo wp_json_encode($response, JSON_PRETTY_PRINT);

        return Handler::QUIT;
    }
940262
public function getResponse()
    {
        $response = new Response();

        $message = new Message();
        $message->setData(['message' => $this->getMessage()]);

        if (!empty($this->getPrivateKey())) {
            $message->setCertificate($this->getCertificate());
            $message->sign($this->getPrivateKey());
        }

        $response->getBody()->write(json_encode($message));

        return $response
            ->withStatus($this->getCode())
            ->withAddedHeader('Content-Type', 'application/json');
    }
985550
public function ajax()
    {
        if (is_null($this->ajax)) {
            $this->ajax = (bool)(defined('DOING_AJAX') && DOING_AJAX);
            $this->ajax = (bool)($this->ajax || parent::ajax());
        }

        return $this->ajax;
    }
676172
public function ajaxGetVisits()
    {
        $data = Base::getVisitsRepository()->orderBy('created_at', 'desc')->take(300)->get(['url', 'browser', 'ip', 'created_at', 'country']);

        return \Response::json(array('data' => $data));
    }
878823
public function getResponse()
    {
        $this->addParameters()->addHeaders();
        $this->options[CURLOPT_RETURNTRANSFER] = true;

        $this->meta = call_user_func($this->map, $this->options);

        return $this->meta['response'];
    }
974804
public function ajax()
    {
        return datatables($this->query())
            ->setTransformer(app($this->transformer))
            ->filterColumn('country_code', function (Builder $builder, $keyword) {
                $countryCode = collect(countries())->search(function ($country) use ($keyword) {
                    return mb_strpos($country['name'], $keyword) !== false || mb_strpos($country['emoji'], $keyword) !== false;
                });

                ! $countryCode || $builder->where('country_code', $countryCode);
            })
            ->filterColumn('language_code', function (Builder $builder, $keyword) {
                $languageCode = collect(languages())->search(function ($language) use ($keyword) {
                    return mb_strpos($language['name'], $keyword) !== false;
                });

                ! $languageCode || $builder->where('language_code', $languageCode);
            })
            ->orderColumn('name', 'name->"$.'.app()->getLocale().'" $1')
            ->make(true);
    }
509480
public function getResponse()
    {
        if (is_null($this->response)) {
            $this->response = $this->getRunner()->run();
        }
        return $this->response;
    }
634422
public function render()
    {
        if ($this->isAfterLastPage()) {
            $this->invokeFinishers();
            $parentResponse = $this->response->getParentResponse();
            if ($parentResponse !== null) {
                foreach ($this->response->getHeaders()->getAll() as $key => $value) {
                    $parentResponse->getHeaders()->set($key, $value, true);
                }
            }
            return $this->response->getContent();
        }

        $this->formState->setLastDisplayedPageIndex($this->currentPage->getIndex());

        if ($this->formDefinition->getRendererClassName() === null) {
            throw new RenderingException(sprintf('The form definition "%s" does not have a rendererClassName set.', $this->formDefinition->getIdentifier()), 1326095912);
        }
        $rendererClassName = $this->formDefinition->getRendererClassName();
        $renderer = new $rendererClassName();
        if (!($renderer instanceof RendererInterface)) {
            throw new RenderingException(sprintf('The renderer "%s" des not implement RendererInterface', $rendererClassName), 1326096024);
        }

        $controllerContext = $this->getControllerContext();
        $renderer->setControllerContext($controllerContext);

        $renderer->setFormRuntime($this);
        return $renderer->renderRenderable($this);
    }