Display Curl Response Sequential one by one

时间:2016-04-15 11:16:35

标签: php curl

I have simple POST CURL request script,

curl_setopt($ch, CURLOPT_URL, $url);                                                              
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);                                                                
curl_setopt($ch, CURLOPT_POSTFIELDS, $body); 
curl_setopt($ch, CURLOPT_POST, 1);
$result = curl_exec($ch);

The problem i am facing is, if i fetch post data from db or i fetch post data from a form, when i process data in large quantity, for example 60 times. The curl displays the output until and unless all 60 requests are completed.

I want the curl to display output one by one not all at once when the query is completed e.g.

Echo 1st Response Echo 2nd Response Echo 3rd Response

1 个答案:

答案 0 :(得分:0)

您要求的内容似乎未定义。

PHP和任何其他HTTP Server只有在知道数据长度时才能开始发送数据。当echo时,您的服务器应该汇总回复,然后组织转移。

如果您想组装文档,可以使用AJAX或任何其他请求/回复系统来组合div个/字段。

一个例子是:

Base文档” - > [N] divs或fields。每个字段都请求其相关处理。 当base接收数据时,它会在其相关的div中组装。