【问题标题】:xmlhttp.send throws exception while using manifest filexmlhttp.send 在使用清单文件时抛出异常
【发布时间】:2011-07-08 13:51:20
【问题描述】:

我在 Chrome 和 MobileSafari 上遇到了一个奇怪的问题(在 IE9 上效果很好)

我有以下代码: 变种产品;

function init()
    {
            var xmlhttp;
            if (window.XMLHttpRequest)
              {// code for IE7+, Firefox, Chrome, Opera, Safari
              xmlhttp=new XMLHttpRequest();
              }
            else
              {// code for IE6, IE5
              xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
              }

            xmlhttp.open("GET","ipad/products.php",false);
            xmlhttp.send();
            products = JSON.parse(xmlhttp.responseText);
            //alert(products.products[0].title);
            getProduct(1);
    }

init被body onload函数调用。

另外,我使用manifest缓存了一些文件:

<HTML manifest="manifest.php">

现在,当我第一次访问该页面时 - 一切正常。 刷新后 xmlhttp.send() 抛出“NETWORK_ERR: XMLHttpRequest Exception 101”

为了再次正常查看页面,我需要清理浏览器缓存

删除清单文件可以解决问题,但我需要它来离线浏览。

有人知道怎么回事吗?

谢谢

【问题讨论】:

    标签: ajax caching google-chrome safari manifest


    【解决方案1】:

    好吧,我通过在 manifest.php 中添加以下行解决了这个问题:

    网络: *

    现在一切正常 我猜主页面也被缓存了,这导致了一些问题。 在 IE 上它可以工作,因为它不支持清单文件

    【讨论】:

    • 我在两个单独的行上有 http://* 和 https://*。在它自己的行上添加孤星“*”使 ajax 再次工作。
    猜你喜欢
    • 2013-05-24
    • 1970-01-01
    • 2013-10-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多