我正在使用HTML5服务器发送事件:
SSEUpdate = new EventSource("update.php");
我希望能够检测到 SSEUpdate.readyState
发生变化。我尝试使用 .onerror
,但是当我使用 console.log(SSEUpdate.readyState)
时,总是得到 0
。 我希望在 readyState
变为 2
时运行我的函数。
readyState
,但我找不到onreadystatechange
,所以它似乎仍然不像 ajax 那样工作,相反你可以在onerror
或onmessage
处理程序内部检查event.target
的readyState
属性,但通常你真的不需要知道这个。你为什么需要知道这个呢? - adeneo