简体   繁体   English

在执行ajax请求时获取响应

[英]Get response while ajax request is being executed

I have a question on which if it is even possible and if so, I would please like to know how! 我有一个问题,如果可能的话,我想知道如何解决!

I am executing an ajax request to some url using POST. 我正在使用POST对某个网址执行ajax请求。 With the request I send data which contains an array. 通过请求,我发送了包含数组的数据。

On the url I request I want to loop through the array of data and while looping through that array I want to give some feedback on my screen like I am now in key-value 1 of 50 from that array. 在url上,我想循环遍历数据数组,并在循环遍历该数组时要在屏幕上提供一些反馈,就像我现在处于该数组的键值1(50)中一样。

Is that possible? 那可能吗? I don't want a 'static' loader as feedback but dynamic content from the processed data on my screen. 我不希望“静态”加载器作为反馈,而希望来自屏幕上已处理数据的动态内容。 Can someone help me out? 有人可以帮我吗?

Kind regards, 亲切的问候,

Pim 皮姆

You want one request and multiple response.. right? 您想要一个请求和多个响应。 As dave said, solution is to use websockets. 正如戴夫所说,解决方案是使用websockets。

Or you can spawn an asynchronous process at server side and have an API/service to check the status of that process. 或者,您可以在服务器端生成异步进程,并具有API /服务来检查该进程的状态。 And keep polling that service from the UI 并继续从用户界面轮询该服务

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM