【问题标题】:alert() in $.get Ajax not Working in IE [duplicate]$.get Ajax 中的 alert() 在 IE 中不起作用 [重复]
【发布时间】:2013-12-06 08:52:27
【问题描述】:

嘿,我在 IE 中遇到了关于 alert() 的有线问题 我正在使用 Jquery Ajax $.get 来获取数据.... 这是代码......

 $(document).ready(function () {

     $("#save").click(function () {
         vars = "pg=13&";
         if ($("#parent_code").val() == "") {
             vars += "type=insert&";
         } else {
             vars += "type=update&";
         }
         vars += $("#parent").serialize();
         $.get("pgs/dpg.php", vars, function (data) {
             $(data).find("row").each(function () {
                 stat = $(this).children(":first-child").text();
                 if (stat == "Saved") {
                     if ($("#parent_code").val() == "") {
                         $("#parent_code").val($(this).children(":nth-child(2)").text());
                         $("#parent_date").val($(this).children(":nth-child(3)").text());
                     }
                 }
                 alert(stat);
                 alert(data);
             });
         });
     });
 });

上述功能有效n在除IE之外的所有浏览器中都显示弹出窗口我不知道我错在哪里......请帮助............

【问题讨论】:

  • 任何人都请帮忙.....!!!!
  • 我正在使用 Internet Explorer 8.0.7
  • jQuery 是哪个版本的?
  • @MikeB jsbeautifier.org 救援 ;)
  • 神圣的古版 jQuery,蝙蝠侠!

标签: javascript ajax jquery


【解决方案1】:

试试这个,应该可以在 IE 8 上运行。

$(data).find("row").each(function () {
    var firstChild = $(this).children().first(),
    stat = firstChild.text();
    if (stat == "Saved") {
        if ($("#parent_code").val() == "") {
            $("#parent_code").val(firstChild.next().text());
            $("#parent_date").val(firstChild.next().next().text());
        }
    }
    alert(stat);
    alert(data);
});

【讨论】:

  • 我的朋友没用......
  • 有没有其他的解决方案......
  • 那你应该把回复交给我们,真的很难理解你喜欢做什么。你是用这个替换所有你的代码还是只替换成功函数中的代码?这段代码不应该中断并且应该触发警报,无论如何都是在我的小提琴中这样做的。
  • 我已经用 urs 替换了我的代码,从 $(data).find("row").each(function () { until });但是 IE 8 中没有显示警报.....
  • 嗯,真奇怪。也许你能告诉我数据变量中有什么。您可以将其添加到您的原始帖子以及您使用的 jQuery 版本吗?
【解决方案2】:

在您发布的代码中,最后缺少一个结束 });

无论如何,您应该使用var vars = ...;var stat = ...;,使用显式的var 关键字来初始化变量。

此外,IE:nth-child 选择器,但您可以找到一些解决方法here

【讨论】:

  • ":nth-child selector is not supported in IE - 在 CSS 中可能,但 jQuery 没有这样的限制。见jquery.com/browser-support
  • 有没有其他选择.....
  • 任何有其他解决方案的人......!!!
猜你喜欢
  • 2012-12-19
  • 2013-09-18
  • 2021-01-14
  • 1970-01-01
  • 1970-01-01
  • 2015-04-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多