Question

I am using jquery for a small webapp and I've built in the option for the app to be available offline - to do so I force reload a page and if it has the correct parameters it uses a simple PHP $_GET to add the manifest line into the html tag, which then triggers the app cache.

I have tried:

$.mobile.changePage

But it fails to trigger the appcache properly. The only way I've been able to do it is to use:

window.location.href = window.location.href + "?appcache=true"

This works! However I get an 'Error Loading Page' for a split second before the page reloads.

Is there a way of either disabling this message or a different way of achieving the same outcome without the message?

Thank you.

Était-ce utile?

La solution 2

I managed to solve the issue by disabling ajax before jQuery mobile has loaded. As in this answer: How To Disable Ajax In jQuery Mobile Before Page Load?

So BEFORE jQuery mobile is called:

<script type="text/javascript" src="jquery"></script>
<script type="text/javascript">
$(document).bind("mobileinit", function () {
    $.mobile.ajaxEnabled = false;
});
</script>
<script type="text/javascript" src="jquerymobile"></script>

This allows me to link to another page running the appcache (and with ajax enabled).

Thanks for your help.

Autres conseils

Have you tried to use two pages, something like this: yourpage.php and yourpageappcache.php and in yourpageappcache.php:

<?php header('Location: yourpage.php?appcache=true');?>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top