更改Server-Sent事件的源(url) [英] Change source (url) of Server-Sent event

查看:89
本文介绍了更改Server-Sent事件的源(url)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改 EventSource 声明中的源集?

How can I change the source set in declaration of EventSource?

我尝试过这样的事情:

I have tried something like this:

var source = new EventSource("/blahblah.php?path=" + (window.location.pathname));
// Few lines later...
source.url = "/blahblah.php?path=" + url;

但是, source.url 保持不变...

But, source.url stays the same...

这甚至可能吗?或者也许有其他方法可以做到这一点?

Is this even possible? Or maybe there are alternative ways to do that?

推荐答案

不,这是不可能的。传递给 EventSource()的新URL会创建一个新的 EventSource 对象。

No, it is not possible. A new URL passed to EventSource() creates a new EventSource object.

这篇关于更改Server-Sent事件的源(url)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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