如何使用jquery获得实时结果? [英] How to get live results with jquery?

查看:80
本文介绍了如何使用jquery获得实时结果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当所有查询返回其值时,我使用PHP和jQuery进行不同的查询,并使用.ajax()获得结果.

I make different queries with PHP and jQuery and I get the results with .ajax(),when all queries return their values.

我想做的就是尽快准备好这些值.现在用户必须等待所有查询完成,但是第一个查询要在第二个查询之前30秒返回其值,所以我不希望用户等待一次查看所有结果,而是希望他们查看结果只是结果返回.

What I want to do is to get those values as soon as they are ready. Now user has to wait until all the queries are done, but the first query returns its value 30 seconds before the second one, so I don't want the user to wait to see all results at once, I want them to see the result just the result returns.

我该怎么做?

推荐答案

如果您正在等待返回多个数据库查询,则可以考虑将Web服务分解为多个AJAX调用.换句话说,发出2个AJAX请求,一个用于第一个查询,另一个用于第二个查询(其值在第一个查询后30秒).这样,您可以在等待任何其他AJAX调用的同时,将第一个查询返回到页面并显示它-或需要执行的任何操作.

If you are waiting for multiple database queries to return, you may consider breaking up your web services into multiple AJAX calls. In other words, make 2 AJAX requests, one for the first query and another for the second query (which gets its value 30 seconds after the first). That way you can return the first query back to the page and display it - or whatever needs to be done - while waiting for any additional AJAX calls.

当然,您可以根据需要将此技术扩展到其他AJAX请求.

Of course you can extend this technique to additional AJAX requests as needed.

这篇关于如何使用jquery获得实时结果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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