首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在使用Atmosphere插件的grails应用程序中刷新页面时,无法加载JS和CSS文件

在使用Atmosphere插件的grails应用程序中刷新页面时,无法加载JS和CSS文件
EN

Stack Overflow用户
提问于 2014-09-10 22:05:31
回答 1查看 186关注 0票数 0

在我的grails 2.3.7应用程序中,我使用了atmosphere meteor 0.8.3。

在我的主页加载时,我订阅客户端。默认情况下,我运行长轮询;它工作得很好。在页面刷新时,我取消订阅客户端。

但是,如果我刷新页面,那么一些JS和CSS将无法加载。它发生在10次刷新中的5次。

我做错什么了吗?(因为我在document.ready()上订阅)。或者我还需要做别的什么吗?

任何帮助都是非常感谢的。

更新:

订阅的gsp内部代码:

代码语言:javascript
复制
$('body').bind('beforeunload',function(){
    Jabber.unsubscribe();
});
$(document).ready(function () { 
    if (typeof atmosphere == 'undefined') {
        Jabber.socket = $.atmosphere;
    } else {
        Jabber.socket = atmosphere;
    }
    var atmosphereRequest = {
        type: 'public',
        url: 'atmosphere/public',
        trackMessageLength: false
    };
    //setTimeout(function(){
        Jabber.subscribe(atmosphereRequest);
    //}, 10000);
});

和Jabber变量

代码语言:javascript
复制
var Jabber = {
    socket: null,
    publicSubscription: null,
    transport: null,

    subscribe: function (options) {
        var defaults = {
            type: '',
            contentType: "application/json",
            shared: false,
            //transport: 'websocket',
            transport: 'long-polling',
            fallbackTransport: 'long-polling',
            trackMessageLength: true
        },
        atmosphereRequest = $.extend({}, defaults, options);
        console.log(atmosphereRequest);
        atmosphereRequest.onOpen = function (response) {
            console.log('atmosphereOpen transport: ' + response.transport);
        };
        atmosphereRequest.onReconnect = function (request, response) {
            console.log("atmosphereReconnect");
        };
        atmosphereRequest.onMessage = function (response) {
            console.log("on message");
            Jabber.onMessage(response);
        };
        atmosphereRequest.onError = function (response) {
            console.log('atmosphereError: ' + response);
        };
        atmosphereRequest.onTransportFailure = function (errorMsg, request) {
            console.log('atmosphereTransportFailure: ' + errorMsg);
        };
        atmosphereRequest.onClose = function (response) {
            console.log('atmosphereClose: ' + response);
        };

        switch (options.type) {
        case 'public':
            Jabber.publicSubscription = Jabber.socket.subscribe(atmosphereRequest);
            break;
        default:
            return false;
        }
        //Jabber.publicSubscription = Jabber.socket.subscribe(atmosphereRequest);

    },

    unsubscribe: function () {
        if (Jabber.socket)
            Jabber.socket.unsubscribe();
    },

    onMessage:function(response){....}
}
EN

回答 1

Stack Overflow用户

发布于 2014-09-11 00:38:31

我是插件的作者。请更新到版本1.0.1。如果您在更新插件后仍然有问题,请使用create a new issue。到时候我们可以解决这个问题。然而,我确实有一个问题。当你说JS加载失败时,你是指atmosphere还是你自己的?没有与CSS相关的插件。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25767526

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档