简体   繁体   English

使用DOJO JavaScript实现反向AJAX

[英]Implement Reverse AJAX using DOJO javascript

I want to implement Reverse AJAX using DOJO javascript framework. 我想使用DOJO javascript框架实现反向AJAX。

Does DOJO provide support out-of-the-box similar to others like DWR? DOJO是否像DWR这样的其他方式提供开箱即用的支持? I am using the latest DOJO. 我正在使用最新的DOJO。 Any reference/examples would be great. 任何参考/示例都很好。

Also what changes would need to be done on the server-side ? 另外,需要在服务器端进行哪些更改? I am using Java. 我正在使用Java。

Well, there is the dojox/socket module which allows you to any WebSocket or Comet (= HTTP long polling) solution. 好吧,有一个dojox/socket模块,它允许您使用任何WebSocket或Comet(= HTTP长轮询)解决方案。

An alternative is the CometD project, this is a solution that uses long polling and allows you to communicate with Java applications (using the CometD Java library) and JavaScript applications (using the CometD Dojo library). 一个替代方案是CometD项目,该解决方案使用长时间轮询,并且允许您与Java应用程序(使用CometD Java库)和JavaScript应用程序(使用CometD Dojo库)进行通信。

However, it is not out of the box with Dojo but is a separate project (the JavaScript lib was included in older versions though). 但是,它不是Dojo的开箱即用,而是一个单独的项目(尽管JavaScript库已包含在旧版本中)。


Your code setup will change, obviously. 很明显,您的代码设置将更改。 First you need to be able to run the CometD Java service, and then you can use ServerSession to publish data or ClientSession to subscribe at the Java side. 首先,您需要能够运行CometD Java服务,然后可以使用ServerSession来发布数据或使用ClientSession在Java端进行订阅。 Going into detail would be too broad, but you should probably read the reference guide . 详细讨论可能太广泛了,但是您可能应该阅读参考指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM