如何在HTTP响应中调用JavaScript函数?

时间:2022-08-23 01:10:49

I'm implementing a web server. I have a chat application on it. When I publish a new message, an HTTP request is generated, it calls the right method in the server (Java), and get a response from the server, includes in its content the new HTML code of the chat page.

我正在实现一个Web服务器。我有一个聊天应用程序。当我发布新消息时,会生成HTTP请求,它会在服务器(Java)中调用正确的方法,并从服务器获取响应,在其内容中包含聊天页面的新HTML代码。

I don't want to refresh the whole page, so I want to call a JavaScript function that will inject the new message to the right div.

我不想刷新整个页面,所以我想调用一个JavaScript函数,将新消息注入正确的div。

How can I do that?

我怎样才能做到这一点?

Thanks, Tomer

1 个解决方案

#1


0  

I think it's better/simpler to use something like jQuery's ajax load.

我认为使用jQuery的ajax加载更好/更简单。

#1


0  

I think it's better/simpler to use something like jQuery's ajax load.

我认为使用jQuery的ajax加载更好/更简单。