I am having a little fun and working with the Streaming API. It was working fine yesterday, and I was able to subscribe without any issues. However, now I am getting this error:

Cannot read property 'init' of undefined

I am pretty certain I have not changed any of the code and the static resources that are being called definitely have not been edited or changed. I even as a precautionary measure updated them again before posting this.


$(function () {
    $("#finalise").click(function () {
            url: window.location.protocol + '//' + window.location.hostname + '/cometd/24.0/',
            requestHeaders: {
                Authorization: 'OAuth {!$Api.Session_ID}'

This should basically initialise the connection on click of a button that I have on my page.

I am absolutely baffled at this, especially with me being new to JQuery :/

Any help would be very largely appreciated!

  • The error suggests that the CometD JavaScript has not bound to jQuery as it should, hence $.cometd is undefined. I suggest you check the "Network" tab of your browser's "Developer Tools" to ensure that both the jQuery and CometD JavaScript was found and then also check for any errors in the JavaScript console. This may help.
    – Keith C
    Jul 22, 2015 at 20:32
  • Have you checked loaded resources that comet files have been loaded? Feb 13, 2016 at 5:43

1 Answer 1


Thanks @Keith for pushing me in the right direction... for some strange reason the CometD library doesn't like the Google API's JQuery -_-

<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>

If this is placed before $.cometd.init(); then it causes an issue.

However, now I also have the issue of when I am calling $.cometd.subscribe() it is also causing issues :/

  • Make sure this cometd plugins js is included; Apr 16, 2016 at 9:47
  • If you can share the js file you have included in which order may help to figure out problem little bit faster; Apr 16, 2016 at 9:48
  • If this post solved your init question, you should accept it as correct.
    – Adrian Larson
    Jul 26, 2016 at 12:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .