Google Gears 和 jQuery 创建托管商店时出现问题
我正在尝试创建一个 ManagedStore 来缓存我正在开发的 Web 应用程序中的所有 js、img、swf 和 css。
这是代码:
$(document).ready(function() {
var manifestName = 'cache_manifest.json';
var storeName = 'cache';
var localServer;
var localStore;
if (window.google && google.gears) {
localRequest = google.gears.factory.create('beta.httprequest');
localServer = google.gears.factory.create('beta.localserver');
localStore = localServer.openManagedStore(storeName);
isServerAvailable();
$("#separator").text(' | ');
if (!localStore) {
localStore = localServer.createManagedStore(storeName);
localStore.manifestUrl = manifestName;
localStore.onerror = $('#offline').text('Error con el cache');
localStore.oncomplete = $('#offline').text('Cache activado');
localStore.onprogress = $('#offline').text(Math.ceil(((event.filesComplete / event.filesTotal) * 100)) + "%");
localStore.checkForUpdate();
}
else {
$('#offline').text('Cache activado');
}
}
});
但是,localStore.onerror 总是会被触发。
我有疑问:
- 你知道出了什么问题吗?
- 我怎样才能看到实际的错误是什么(alert(localStore.onerror) 不起作用)
问候,
I'm trying to create a managedStore to cache all the js, img, swf and css from a web app I'm developing.
Here is the code:
$(document).ready(function() {
var manifestName = 'cache_manifest.json';
var storeName = 'cache';
var localServer;
var localStore;
if (window.google && google.gears) {
localRequest = google.gears.factory.create('beta.httprequest');
localServer = google.gears.factory.create('beta.localserver');
localStore = localServer.openManagedStore(storeName);
isServerAvailable();
$("#separator").text(' | ');
if (!localStore) {
localStore = localServer.createManagedStore(storeName);
localStore.manifestUrl = manifestName;
localStore.onerror = $('#offline').text('Error con el cache');
localStore.oncomplete = $('#offline').text('Cache activado');
localStore.onprogress = $('#offline').text(Math.ceil(((event.filesComplete / event.filesTotal) * 100)) + "%");
localStore.checkForUpdate();
}
else {
$('#offline').text('Cache activado');
}
}
});
However, localStore.onerror always get's triggered.
I have to questions:
- Any ideas what's going wrong?
- How can I see what's the actual error ( alert(localStore.onerror) won't work)
Regards,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试
您必须分配对函数的引用,这些函数应该在定义的事件上调用。 你所做的就是调用这些函数,最后 onerror、oncomplete 和 onprogress 属性保存 $('#offline').text('...') 返回的 jQuery 实例
try
you have to assign references to functions, that should be called on defined events. What you did was calling these functions, and on the end the onerror, oncomplete and onprogress properties held jQuery instances returned by $('#offline').text('...')