$.get-Ajax中的alert()在IE中不工作

alert() in $.get Ajax not Working in IE

本文关键字:IE 工作 get-Ajax 中的 alert      更新时间:2024-04-04

嘿,我在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);
             });
         });
     });
 });

上面的功能可以在所有浏览器中显示弹出窗口,除了IE我不知道我错在哪里了。。。。。请帮忙。。。。。。。。。

试试这个,应该能在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);
});

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

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

此外,:nth-child选择器在IE<9,但你可以在这里找到一些变通方法。