aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/server-sent_events/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'files/zh-cn/web/api/server-sent_events/index.html')
-rw-r--r--files/zh-cn/web/api/server-sent_events/index.html78
1 files changed, 78 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/server-sent_events/index.html b/files/zh-cn/web/api/server-sent_events/index.html
new file mode 100644
index 0000000000..a6e44fee83
--- /dev/null
+++ b/files/zh-cn/web/api/server-sent_events/index.html
@@ -0,0 +1,78 @@
+---
+title: Server-sent events
+slug: Web/API/Server-sent_events
+tags:
+ - API
+ - NeedsTranslation
+ - Server-sent events
+ - TopicStub
+translation_of: Web/API/Server-sent_events
+original_slug: Server-sent_events
+---
+<div>{{DefaultAPISidebar("Server Sent Events")}}</div>
+
+<p>一个网页获取新的数据通常需要发送一个请求到服务器,也就是向服务器请求的页面。使用 server-sent 事件,服务器可以在任何时刻向我们的 Web 页面推送数据和信息。这些被推送进来的信息可以在这个页面上作为 <em><a href="https://wiki.developer.mozilla.org/en-US/docs/DOM/event">Events</a> + data</em> 的形式来处理。</p>
+
+<h2 id="概念与使用">概念与使用</h2>
+
+<p>可以前往我们这篇文章 <a href="/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events">《使用 “server-sent events</a>”》 学习怎么使用 server-sent events。</p>
+
+<h2 id="接口">接口</h2>
+
+<dl>
+ <dt>{{domxref("EventSource")}}</dt>
+ <dd>Defines all the features that handle connecting to a server, receiving events/data, errors, closing a connection, etc.</dd>
+</dl>
+
+<h2 id="示例">示例</h2>
+
+<ul>
+ <li><a href="https://github.com/mdn/dom-examples/tree/master/server-sent-events">Simple SSE demo using PHP</a></li>
+</ul>
+
+<h2 id="规范">规范</h2>
+
+<table class="standard-table">
+ <thead>
+ <tr>
+ <th scope="col">规范</th>
+ <th scope="col">状态</th>
+ <th scope="col">备注</th>
+ </tr>
+ </thead>
+ <tbody>
+ <tr>
+ <td>{{SpecName('HTML WHATWG', '#server-sent-events', 'Server-sent events')}}</td>
+ <td>{{Spec2('HTML WHATWG')}}</td>
+ <td></td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="参见">参见</h2>
+
+<h3 id="Tools">Tools</h3>
+
+<ul>
+ <li><a href="https://github.com/EventSource/eventsource">EventSource polyfill for Node.js</a></li>
+ <li>Remy Sharp’s <a class="link-https" href="https://github.com/remy/polyfills/blob/master/EventSource.js">EventSource polyfill</a></li>
+ <li>Yaffle’s <a class="link-https" href="https://github.com/Yaffle/EventSource">EventSource polyfill</a></li>
+ <li>Rick Waldron’s <a class="link-https" href="https://github.com/rwldrn/jquery.eventsource">jquery plugin</a></li>
+ <li>intercooler.js <a href="http://intercoolerjs.org/docs.html#sse">declarative SSE support</a></li>
+</ul>
+
+<h3 id="相关话题">相关话题</h3>
+
+<ul>
+ <li><a href="/en-US/docs/AJAX">AJAX</a></li>
+ <li><a href="/en-US/docs/JavaScript">JavaScript</a></li>
+ <li><a href="/en-US/docs/WebSockets">WebSockets</a></li>
+</ul>
+
+<h3 id="其他资源">其他资源</h3>
+
+<ul>
+ <li>一个使用 server-sent events 的、类似 <a href="http://hacks.mozilla.org/2011/06/a-wall-powered-by-eventsource-and-server-sent-events/">Twitter</a> 的应用程序,代码存放在这里:<a href="https://github.com/mozilla/webowonder-demos/tree/master/demos/friends%20timeline">Github</a>.</li>
+ <li><a href="http://dsheiko.com/weblog/html5-and-server-sent-events">HTML5 和 Server-sent events</a></li>
+ <li>使用<a href="http://rajudasa.blogspot.in/2012/05/html5-server-sent-events-using-aspnet.html">Asp.Net</a> 的 <a href="http://rajudasa.blogspot.in/2012/05/html5-server-sent-events-using-aspnet.html">Server-sent events</a> 的指南</li>
+</ul>