cUrl 请求每 2 秒一次并回显结果



我希望每 2 秒发送一次 cUrl 变量,并在页面中显示结果。我正在使用 Ajax,但是我如何使用函数参数发送 cUrl 详细信息?

感谢帮手,祝你有美好的一天:)

你可以像这样每两秒调用一次 ajax 函数 uning setInteval 的 js 函数

setInterval(your_ajax_function,2000); // call your_ajax_function in every 2 seconds
function your_ajax_function()
{
    // ajax function statements here
    // and send request to the php file
    // get output from php file as response
    // show response in your desired div
}   

现在在php文件中,您可以调用curl函数等,并将输出作为echo

带有 PhP 的 CURL 仍然像所有 PhP 代码一样基于服务器。我自己能想到的每 2 秒发送一次请求的唯一方法是每 2 秒强制刷新一次相关页面。

    $requiredPage = "example.com";
    header('Refresh:2;url='.$requiredPage);

最新更新