Domanda

Sto cercando di creare una semplice pagina HTML di prova che mostra i messaggi da un server Bayeux.

Questo è il codice:

  <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>

Quando provo ad aprire questa pagina ricevo il seguente errore JavaScript: ORG non è definito alla riga 20 di JQuery.cometd.js. La linea in questione è:

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

Questa è una biblioteca che ho scaricato e immagino di fare qualcosa di sbagliato qui, ma non ho idea di cosa sia.

Grazie in anticipo, Micha

Nessuna soluzione corretta

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top