【问题标题】:SCRIPT5009: 'String' is undefined IE9SCRIPT5009:“字符串”未定义 IE9
【发布时间】:2013-10-23 13:04:29
【问题描述】:

我使用 jquery-1.7.2.min.js

我有以下 javascript:

$(function() {
    $("#del_category").click(function() {
        if (confirm('Are you sure you want to delete this category?')) {
            $.ajax({
                type: "POST",
                url: "someurl",
                datatype: "json",
                csd: window.parent.CSD,
                success: function(data) {
                    if (data.isSuccess) {
                        if (data.isFree) {
                            // error appears if this function invokes
                            this.csd.Popup.currentWindow.hideDialog();
                        } else {
                            alert("Category uses in some FAQ.");
                        }
                    } else {
                        alert("Error. Category was not deleted.");
                    }
                }
            });
        }

        return false;
    });
});

它在除 IE9 之外的所有浏览器中都能正常工作。在 IE9 中它可以正常工作(调用所有函数)但显示 js 错误:SCRIPT5009: 'String' is undefined

我该如何解决这个问题?

编辑

此脚本可以正常运行:

$(function() {
    $("#del_category").click(function() {
        window.parent.CSD.Popup.currentWindow.hideDialog();
    });
});

错误仅出现在 ajax OnSuccess 事件处理程序中。

【问题讨论】:

  • 您显示的代码中没有对String 的引用。你能告诉我们导致错误的具体代码行吗?
  • 小提琴还是现场直播??
  • 出现在 jquery-1.7.2.js 的 509 行: type: function( obj ) { return obj == null ?字符串( obj ) : class2type[oString.call(obj)] || “目的”; },
  • 因为这是正确执行但您只在 IE 中收到错误,这可能是由拼写错误引起的吗?我相信datatype 应该是dataType

标签: jquery ajax internet-explorer-9 undefined


【解决方案1】:

尝试将hideDialog(); 放入setTimeout。我相信错误即将出现,因为对话框在 jQuery 完成之前已被处理。

$(function() {
    $("#del_category").click(function() {
        if (confirm('Are you sure you want to delete this category?')) {
            $.ajax({
                type: "POST",
                url: "someurl",
                datatype: "json",
                csd: window.parent.CSD,
                success: function(data) {
                    if (data.isSuccess) {
                        if (data.isFree) {
                            // error appears if this function invokes
                            var csd = this.csd;
                            setTimeout(function() {
                                csd.Popup.currentWindow.hideDialog();
                            }, 0);
                        } else {
                            alert("Category uses in some FAQ.");
                        }
                    } else {
                        alert("Error. Category was not deleted.");
                    }
                }
            });
        }

        return false;
    });
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-09-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-02-22
    • 1970-01-01
    • 2013-12-16
    • 1970-01-01
    相关资源
    最近更新 更多