-3

Hey I am facing a wired prob regarding alert() in IE I am using Jquery Ajax $.get to get data .... here is the code......

 $(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);
             });
         });
     });
 });

The above function works n shows popup in all browsers except IE I don't know where I am mistaken..... please help.........

bogatyrjov
  • 5,317
  • 9
  • 37
  • 61

2 Answers2

-1

Try this, should work on 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);
});
-2

In the code you've posted you are missing a closing }); at the end.

Anyway, you should probably use var vars = ...; and var stat = ...;, using the explicit var keyword to initialize the variables.

Furthermore, :nth-child selector is not supported in IE<9, but you can find some workaround here.

Community
  • 1
  • 1
alexcasalboni
  • 1,726
  • 1
  • 16
  • 26