Hi I am quite new to java script and i am looking a working example to call back ends using java script channel API . I do not have any idea about channel API . Can anyone provide me a working example
相关问题
- Is there a limit to how many levels you can nest i
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to toggle on Order in ReactJS
- How to get the background from multiple images by
If you're asking how to get a message from the backend to a javascript client: you can't send messages from a backend server to a channel created on a frontend server. This is because the app version number is included in the channel token, and backends have a different app version than frontends. You could, however, implement a servlet in your backend that calls createChannel and returns it to your frontend for inclusion in javascript that your frontend renders.
If you're trying to send a message to a backend from your javascript code, you won't be able to use XmlHttpRequest directly because of the same-origin policy (this assumes your clients are rendered from a non-backend instance). You could get around this using JSONP, or by routing XHR requests from your frontend to your backend in a frontend servlet.
Did you see the docs? Java / Python