質問

I am trying to create a simple test HTML page which shows messages from a Bayeux server.

this is the code:

  <html>
  <head>
     <title>test Baeyux connexion</title>
     <script type="text/javascript" src="jquery/jquery-1.6.2.js"></script>
     <script type="text/javascript" src="jquery/jquery.cometd.js"></script>
     <script type="text/javascript" src="jquery/json2.js"></script>
  </head>
  <body>
  <script type="text/javascript">
     jQuery( document ).ready( function ( $ ) {
        var cometd = $.cometd;

        cometd.init( 'http://localhost:8080/VisionWeb/cometd' );
        cometd.addListener( "/meta/handshake", function ( message ) {

        } );

        cometd.addListener( '/meta/connect', function ( message ) {
           // if (cometd.getStatus() === 'disconnecting' || cometd.getStatus() === 'disconnected')
           if ( cometd.isDisconnected() ) // Available since 1.1.2
           {
              return;
           }
           var wasConnected = _connected;
           _connected = message.successful;
           if ( !wasConnected && _connected ) {
              $( "#con" ).text( "RECONNECTED" );
           }
           else if ( wasConnected && !_connected ) {
              $( "#con" ).text( "DISCONNECTED" );
           } else if ( _connected ) {
              $( "#con" ).text( "ON" );
           } else {
              $( "#con" ).text( "OFF" );
           }
        } );

        cometd.addListener( '/meta/disconnect', function ( message ) {
           if ( message.successful ) {
              _connected = false;
           }
        } );
     });
  </script>
  <p>connexion is <span id="con">UNDEFINED</span></p>

  <p>comet messages</p>
  <ul id="msg"></ul>
  </body>
  </html>

when I try to open this page I get the following javascript error: org is not defined at line 20 of jquery.cometd.js. The line in question is:

org.cometd.JSON.toJSON = JSON.stringify;

this is a library I downloaded and I guess I am doing something wrong here but I have no clue as to what it is.

thanks in advance, Micha

正しい解決策はありません

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top