1

I am using this websocket programming from here.https://github.com/knowledgecode/WebSocket-for-Android.But after following the steps i am getting this error.I am using cordova 2.7 .can you please tell me how to sove this prolem

Uncaught TypeError: Object #<Object> has no method 'exec' at file:///android_asset/www/js/webSocket.js:51

here is my html file..

<html>
    <head>
        <meta charset="utf-8" />
        <meta name="format-detection" content="telephone=no" />
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
        <link rel="stylesheet" type="text/css" href="css/index.css" />
        <title>Hello World</title>
    </head>
    <body>
        <div class="app">
            <h1>Apache Cordova</h1>
            <div id="deviceready" class="blink">
                <p class="event listening">Connecting to Device</p>
                <p class="event received">Device is Ready</p>
            </div>
        </div>
        <script type="text/javascript" src="cordova.js"></script>
         <!--script type="text/javascript" src="js/webSocket.min.js"></script-->
           <script type="text/javascript" src="js/webSocket.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
        <script type="text/javascript">
        var ws = new plugins.WebSocket('ws://192.168.1.102/8101');

// onopen callback
ws.onopen = function () {
    console.log('onopen');
    this.send('hello');
};

// onmessage callback
ws.onmessage = function (data) {
    // The data is received text
    console.log(data);  // hello
    this.close();
};

// onerror callback
ws.onerror = function (message) {
    // The message is the reason of error
    console.log(message);
};

// onclose callback
ws.onclose = function (code) {
    // The code is the reason code of disconnection
    console.log(code);  // 1000
};
           // app.initialize();
        </script>
    </body>
</html>

If you call your procedure like this

Exec sp_getClientTransactioninfo '2001-01-01'

Then you are going to get an error saying that the procedure expects the missing parameter @ToDate. The missing parameter is not set as null, it is just not there so SQL server throws an error saying it was expecting the parameter before even executing your procedure.

You can get around this, by setting your parameters to null in the declaration of your procedure, like so:

Alter PROCEDURE sp_getClientTransactioninfo
@FromDate DATETIME = null,
@ToDate DATETIME = null,
@Active int

So if you do not provide the parameter, it will default to null and then your error message with show.

You may also want to look into RAISEERROR rather then PRINT

4

1 回答 1

0

一种可能性是您的一个库(cordova.js、webSocket.js)正在扩展 Object.prototype,另一种是使用对象作为哈希表而不检查 hasOwnProperty()。如果是这种情况,您将需要找到其中一个库的替代品或自行开发。请参阅此相关问题

于 2013-08-28T16:37:10.637 回答