使用ajax每秒刷新div并使用现有div显示新div [英] Refresh div every seconds with ajax and show new div with existing div

查看:89
本文介绍了使用ajax每秒刷新div并使用现有div显示新div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网页,我想显示加入我网站的用户列表以及它们之间的连接。

I have 1 web page where I want to display list of users joined to my web site and connections between them.

我有用户和他们之间的联系:

I have users and connections between them:

 var data=[
           {
              "Id": 38,
               "Connections":[39,40],
               "Name":"ABc"
          },
           {
              "Id": 39,
               "Connections":[40],
               "Name":"pqr"
           },
           {
               "Id": 40,
               "Connections":[],
               "Name":"lmn"
           }]

在上面的示例用户中 Id:38 连接到用户39和40 用户39连接到用户40和用户40 已连接到用户39和用户38,因此用户40连接数组为空白

In the above example user with Id:38 is connected to user 39 and 40 and user 39 is connected to user 40 and user 40 is already connected to user 39 and user 38 so user 40 Connection array is blank.

我有一个网络服务,我将每1-2秒显示一次此页面上新加入的用户以及我存储在我的表中的现有用户之间的新连接以及此Web服务将获取所有用户及其连接。

I have a web service which I will fires every 1-2 seconds to display newly joined users on this page and new connection between existing users which I have stored in my table and this web service will fetch all users along with their connections.

所以一开始我的页面将加载,但之后我的页面将不会刷新,新的用户应该显示,新的连接应该与AJAX调用我的网络服务连接。

So at first my page will load but after then my page will not refresh and new users should be displayed and new connections should be connected with AJAX call to my web service.

到目前为止我已成功设法显示用户和他们之间的连接,但现在在1-2秒内停留自动刷新div,以便在不进行先前连接的情况下建立新连接。

So far I have been successfully manage to display users and connection between them but now stuck with auto refresh div in 1-2 seconds so that new connections are made without making previous connections.

对现在发生了什么,当我刷新我的div以前的连接再次进行。

Right now what happening is when I refresh my div previous connections are made again.

我正在使用这个插件: Jquery-connections.js

I am using this plugin:Jquery-connections.js

这是我做的一个演示;请忽略我保存在html中的js,因为它是插件(Jquery-connections.js): JS bin Demo

This is one demo which I made; please ignore js which i have kept in html because that is plugin (Jquery-connections.js):JS bin Demo

推荐答案

根据讨论要点,我们已达成解决问题的方法:

As per the discussion points we have reached to resolve the issues :


  • 用画布替换div元素以简化和更快地渲染。

  • 使用第三方js库将节点和边缘渲染到画布中。

这篇关于使用ajax每秒刷新div并使用现有div显示新div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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