【问题标题】:Internet Explorer doesn't execute jQuery.load (Firefox does)Internet Explorer 不执行 jQuery.load(Firefox 执行)
【发布时间】:2012-02-16 06:44:22
【问题描述】:

我正在尝试制作一个非常简单的 CMS 系统,到目前为止一切都很好。 但是现在当我尝试将编辑页面加载到 div (.load - jQuery) 时,IE 不会显示它,而 Firefox 会。

这是我的加载代码

function edit_item(id){
    $('#row_'+id).load("actions/edit.php?id="+id, function(response, status, xhr) {
      if (status == "error") {
        var msg = "Sorry but there was an error: ";
        $('#row_'+id).html(msg + xhr.status + " " + xhr.statusText);
      }
    });
}

这是我要加载的页面

<?php
include('connect.php');
$item = resultset;
?>
<script>
$(function() {
    $("#datepicker").datepicker();
    $("#datepicker").datepicker("option", "dateFormat", "yy-mm-dd");
    var currentdate = $("#currentdate").val()
    $("#datepicker").datepicker('setDate', currentdate);

});
</script>
<form method="POST" action="actions/update.php">
    <input type="hidden" id="currentdate" value="<?=$item['datum']?>">
    <table style="border: 1px solid black; margin-left: 10px; width: 620px;">
        <tbody>
        <tr>
            <td>Titel</td>
            <td><input type="text" name="titel" class="input" style="width: 560px;" value="<?=$item['titel']?>"></td>
        </tr>
        <tr>
            <td>Datum</td>
            <td><input type="text" name="datum" class="input" id="datepicker" style="width: 560px;"></td>
        </tr>
        <tr>
            <td>Bericht</td>
            <td><textarea name="inhoud" class="input" style="width: 560px; height: 300px;"><?=$item['inhoud']?></textarea></td>
        </tr>
        <tr>
            <td>Foto's</td>
            <td>
                <input type="file" name="foto[]">
                <input type="file" name="foto[]">
                <input type="file" name="foto[]">
                <input type="file" name="foto[]">
                <input type="file" name="foto[]">
                <input type="file" name="foto[]">
            </td>
        </tr>
        <tr>
            <td colspan="2"><input type="submit" id="toevoegen" value="Updaten" class="input" style="float:right; margin-right: 5px; margin-top: 5px;"></td>
        </tr>
        </tbody>
    </table>
    <input type="hidden" name="id" value="<?=$_GET['id']?>">
    <input type="hidden" name="aktie" value="item">
</form>

Internet Explorer 给我这个错误:

抱歉,出现错误:0 错误:无法完成 由于错误 c00ce56e 导致的操作。

解决方案: header('Content-Type: text/html; charset=UTF-8'); 可以解决问题,但 IE 已将其缓存。当我清除它时 - 它又开始工作了,所以谢谢!

【问题讨论】:

  • 我喜欢 Dear StackOver(flowers)
  • 请在下方发布您的解决方案,然后接受您自己的答案。在回答您自己的问题时,这是使用本网站的最恰当方式。
  • 另外,我看到@BenP 的帖子导致了答案。您应该支持他并接受这一点(他也需要改进他的答案)。

标签: jquery internet-explorer xmlhttprequest


【解决方案1】:

谷歌搜索错误代码似乎表明问题在于 XHR 响应的编码。

如果您将 XMLHttpRequests 的编码标头设置为 header('Content-Type' , 'text/html; charset=utf8');而不是 header('Content-Type', 'text/html; charset=UTF-8'); IE7 会给出漂亮而清晰的错误 c00ce56e。

见:http://blog.shpare.com/2008/03/04/error-c00ce56e-in-ie/

【讨论】:

  • 假设您是社区的新手,这里有一些提示可以改进您的答案: 1) 不要用问题来回答问题。 :) 2)在您的答案中添加一些代码 sn-p/suggestion。您可以引用它说“如本文所述......”但不要将它们发送到另一个链接。如果您遵循这些提示,我相信您会获得更多支持。
  • @Mrchief,是的好主意。我会改进这个答案,但我不确定它会帮助赞成/接受 - 我已经收到 Delano de Rooij 的回复(现已删除),说我的回复没有帮助。 :)
【解决方案2】:

从 2.6 版开始,MSXML 将所有 XML 文档通过 Mlang.dll 传递给 验证他们的编码。如果 Mlang.dll 遇到非标准编码 字符串,它返回一个错误。

"ISO8859_1" 是 Latin-1 字符的规范表示 Java 语言和类库中的编码字符串。标准 但是,由互联网号码分配机构定义, 是“ISO-8859-1”,这是不可接受的别名。

http://support.microsoft.com/kb/304625

检查内容类型的字符集。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-13
    • 1970-01-01
    • 2014-02-03
    • 1970-01-01
    相关资源
    最近更新 更多