D
D
DeniSidorenko2020-05-19 08:52:04
PHP
DeniSidorenko, 2020-05-19 08:52:04

How to send JSON response instead of php redirect?

Hello, the situation is as follows, after submitting the forms, there is a redirect script

$this->response->redirect($this->url->link('information/contact/success'));

How can I send him a json code, so that instead of a redirect, I would run a script to open a popup. Thanks

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Ukolov, 2020-05-19
@DeniSidorenko

json code so that instead of a redirect, I would run a script
JSON is an object , not a code , it is needed to transfer data , and a front-end script can already perform some actions based on this data .
You didn't specify what framework is used on the server, but since it's there $response->redirect(), it $response->json()'s probably also.

T
Timur Khudiyev, 2020-05-19
@t_khudiyev

Or, as Aleksey Ukolov said , or at the beginning of the action, indicate in the header that Json will be returned and simply return an array.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question