我将如何根据数据库更新我的UI [英] How I will update my ui according to database

查看:85
本文介绍了我将如何根据数据库更新我的UI的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更新我的网页,因为db中发生了变化。我不知道怎么办

你可以给我一些建议吗



我尝试了什么:



我使用元标记进行页面刷新是显示数据库的当前值

但是我想在db

I want to update my webpage as changing happenes in db.I don't know how to do
can u give me some suggestion

What I have tried:

I have used meta tag for page refresh yes its showing current value for database
but I want to refresh my page when changes happens in db

推荐答案

中发生更改时刷新我的页面你遇到了问题,因为HTTP / HTTPS仅适用于浏览器生成的地方请求和服务器响应请求的页面。 HTTP / HTTPS服务器永远不会将内容推送到浏览器。



那么其他页面如何显示正在发生的事情呢?他们不使用HTTP / HTTPS。它们使用单​​独的套接字服务器,浏览器中运行的javascript代码连接到该服务器。使用套接字服务器,您可以在浏览器和服务器之间进行双向通信。服务器可以将所需的任何内容推送到客户端,javascript代码可以相应地更新浏览器中显示的HTML。



有些库可以封装所有这些对你而言,例如 SignalR [ ^ ]。
You've got a problem because HTTP/HTTPS only works where the browser makes a request and the server responds with the page requested. HTTP/HTTPS servers NEVER PUSH CONTENT to a browser.

So how do other pages give the appearance that that's what going on? They don't use HTTP/HTTPS. They use a separate socket server that javascript code running in the browser connects to. With a socket server you get two-way communication between the browser and server. The server gets to push whatever it needs to to the client and the javascript code can update the HTML being shown in the browser accordingly.

There are libraries that encapsulate all this for you, such as SignalR[^].


这篇关于我将如何根据数据库更新我的UI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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