关闭CURL请求 [英] Shut down a CURL request

查看:284
本文介绍了关闭CURL请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用CURL请求从API检索一些数据。

I am trying to retrieve some data from an API using CURL request. Is it possible to track the time passed from request start and stop the request after sometime, may be less then the timeout set to it?

注意:是否可以跟踪从请求开始到结束请求所经过的时间,有时可以小于设置的超时时间? strong>

NOTE:

我的目标是不设置超时。让请求继续进行,直到没有另一个作业/功能调用。

My aim is to not set timeout. Let the request continue until another job/function call don't arise. Is it possible?

详细信息:

我真正想要的是那个,我有一个函数,该函数通过Ajax调用,然后启动CURL,另一个Ajax也将使用某些特定参数调用该函数,当第二次Ajax调用发生时,CURL的执行应停止。但是这两个调用之间的时间间隔是任意的。

What I exactly want is that, I have a function that call through Ajax and then a CURL start, and another Ajax will also call that function with some specific parameter, when second ajax call happen then the execution of CURL should stop. But the time interval within these two call is arbitrary.

推荐答案


我真正想要的是,我有一个通过Ajax调用并随后启动CURL的函数,另一个Ajax也会使用某些特定参数调用该函数,当第二次Ajax调用发生时,CURL的执行应停止

what I exactly want is that, I have a function that call through Ajax and then a CURL start, and another Ajax will also call that function with some specific parameter, when second ajax call happen then the execution of CURL should stop

然后,您需要在JavaScript代码中执行此操作。在发送新请求之前,只需 .abort()上一个AJAX请求即可。

Then you need to do that in your JavaScript code. Simply .abort() the previous AJAX request before sending a new one.

这篇关于关闭CURL请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆