Y
Y
yalex14422015-10-15 23:29:42
PHP
yalex1442, 2015-10-15 23:29:42

How to return multiple json in one web request?

Hi all!
How is it possible by sending one ajax to receive data and process it immediately, without waiting for the end of the request?
i.e. I want to receive json arrays (links to photos) and immediately display them within a single request
on the server php - codeigniter is spinning.
I don’t want to shoot a lot of ajax on a request for each portion of data. (due to constant re-opening of connections to the db, reloading the framework core, etc.)
in the direction of which technology to look at, tell the composer library, etc.?
UPD. in theory, there is no problem sending several ajax from the client, but I want everything to be processed by one process on the server

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2015-10-15
@yalex1442

1) throw out codeigniter and rewrite everything in reactphp
2) instead of inventing drug addiction, don’t worry and do like everyone else, stateless apishki and all that. keep-alive minimize the cost of establishing an http connection, and to optimize the work with the database, you can simply use persistent connections, etc.
3) throw out codeigniter and rewrite on any framework using PSR-7 or symfony/httpkernel, armed with php-pm .

I
index0h, 2015-10-16
@index0h

How is it possible by sending one ajax to receive data and process it immediately, without waiting for the end of the request?

You are looking for websockets. But there are a lot of nuances.
What's the problem then? You wrap it in a certain collection and you already serialize it into json.
NO! Do not poke the corpse with a stick, let it leave with dignity.
You are trying to solve a contrived problem in a way that won't solve it.
The load from the database is usually removed due to:
* index settings
* query optimization
* caching.
...
Cool, why do you need php then?
At least:
* SOLID
* PSR-2,3,4,7
* Symfony / Silex

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question