开发者

Error in Javascript causes page in IE to stop running javascript

On my website, I have a reference to a javascript file, and on IE, this error is thrown:

send: function (data) {
    /// <summary>Sends data over the connection</summary>
    /// <param name="data" type="String">The data to send over the connection</param>
    /// <returns type="signalR" />
    var connection = this;

    if (!connection.transport) {
        // Connection hasn't been started yet
        throw "SignalR: Connection must be started before data can be sent. Call .start() before .send()";
    }

    connection.transport.send(开发者_JAVA技巧connection, data);

    return connection;
},

That throw is being caught by Internet Explorer, and it appears to halt any other javascript from running.

Error in Javascript causes page in IE to stop running javascript

What can I do so that error doesn't completely halt everything on my page?


Why are you using throw if you don't want to throw the exception? consider this, if you want the exception for logging purposes:

if (!connection.transport) {
    // Connection hasn't been started yet
    setTimeout(function() {
        throw "SignalR: Connection must be started before data can be sent. Call .start() before .send()"; 
    }, 0);
    return;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜