Loading ...
Sorry, an error occurred while loading the content.

Ajax don't work on IE7 but works fine in Firefox - help on that.

Expand Messages
  • Filipe La Ruina
    Hey guys, i m new to AJAX and i m trying to make that good n old related combo boxes (like, country - state). Although in my code the ids and names of the
    Message 1 of 4 , Jun 8, 2008
    • 0 Attachment
      Hey guys, i'm new to AJAX and i'm trying to make that good n old
      related combo boxes (like, country -> state). Although in my code the
      ids and names of the combos are dinamycally made (because I have 10
      different combos) well it worked really well on firefox, although,
      when I tryed in Internet Explorer 7 it didn't work, here is the code:

      function Ajax(uf,n){
      var xmlHttp;
      var url = "scripts/selecionamun.php?uf="+uf;
      var browser=navigator.appName;
      alert(n);
      if (browser == "Microsoft Internet Explorer") {
      try {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
      catch (e) {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
      }else {
      xmlHttp=new XMLHttpRequest();
      }
      xmlHttp.onreadystatechange=function() {
      if(xmlHttp.readyState==4) {
      document.getElementById(n).innerHTML = xmlHttp.responseText;
      alert(document.getElementById(n));
      }
      }
      xmlHttp.open("GET",url,true);
      xmlHttp.send(null);
      }

      Explaining the alerts:
      The first one i put there just to see if he's getting the right combo
      to populate with data, and it is getting the id right
      The second Alert show me the object he is getting, and in Firefox it
      says [Object HTMLSelectElement] (look like perfect since im doing the
      code with a select element) and in IE it shows only [object] (i think
      thats the problem maybe?)

      Well FF puts the data in the box the way it should, although IE just
      erase what was already writen (it was written --Select--)
      If anyone can help I thank you :)

      PS: Im brazilian, so sorry for any kind of mistyping :P and in fact
      it is not a country -> state box its a State -> city (named UF(state)
      in the code)
    • Daniel Israel
      Just off the top of my head... you should check to see if the XMLHttpRequest object is available first and use that. IE7 will use that now instead of an
      Message 2 of 4 , Jun 9, 2008
      • 0 Attachment
        Just off the top of my head... you should check to see if the
        XMLHttpRequest object is available first and use that. IE7 will use
        that now instead of an ActiveXObject.

        On Jun 8, 2008, at 11:02 AM, Filipe La Ruina wrote:

        > Hey guys, i'm new to AJAX and i'm trying to make that good n old
        > related combo boxes (like, country -> state). Although in my code the
        > ids and names of the combos are dinamycally made (because I have 10
        > different combos) well it worked really well on firefox, although,
        > when I tryed in Internet Explorer 7 it didn't work, here is the code:
        >
        > function Ajax(uf,n){
        > var xmlHttp;
        > var url = "scripts/selecionamun.php?uf="+uf;
        > var browser=navigator.appName;
        > alert(n);
        > if (browser == "Microsoft Internet Explorer") {
        > try {
        > xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        > }
        > catch (e) {
        > xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
        > }
        > }else {
        > xmlHttp=new XMLHttpRequest();
        > }
        > xmlHttp.onreadystatechange=function() {
        > if(xmlHttp.readyState==4) {
        > document.getElementById(n).innerHTML = xmlHttp.responseText;
        > alert(document.getElementById(n));
        > }
        > }
        > xmlHttp.open("GET",url,true);
        > xmlHttp.send(null);
        > }
        >
        > Explaining the alerts:
        > The first one i put there just to see if he's getting the right combo
        > to populate with data, and it is getting the id right
        > The second Alert show me the object he is getting, and in Firefox it
        > says [Object HTMLSelectElement] (look like perfect since im doing the
        > code with a select element) and in IE it shows only [object] (i think
        > thats the problem maybe?)
        >
        > Well FF puts the data in the box the way it should, although IE just
        > erase what was already writen (it was written --Select--)
        > If anyone can help I thank you :)
        >
        > PS: Im brazilian, so sorry for any kind of mistyping :P and in fact
        > it is not a country -> state box its a State -> city (named UF(state)
        > in the code)
        >
        >
        > ------------------------------------
        >
        > Visit http://aiaiai.com for more groups to joinYahoo! Groups Links
        >
        >
        >

        -D. Israel
        dan@...
        http://www.customcodebydan.com
        AIM: JudoDanIzz



        [Non-text portions of this message have been removed]
      • Filipe La Ruina
        In fact the XMLHttpRequet is working ok, since I already put some debugging to see if that is working... there is another problem =/ Oh and I ve read somewhere
        Message 3 of 4 , Jun 9, 2008
        • 0 Attachment
          In fact the XMLHttpRequet is working ok, since I already put some
          debugging to see if that is working... there is another problem =/
          Oh and I've read somewhere that the innerHTML editing dont work on
          IE7, someone can confirm that?

          --- In JavaScript_Official@yahoogroups.com, Daniel Israel <dan@...>
          wrote:
          >
          >
          > Just off the top of my head... you should check to see if the
          > XMLHttpRequest object is available first and use that. IE7 will
          use
          > that now instead of an ActiveXObject.
          >
          > On Jun 8, 2008, at 11:02 AM, Filipe La Ruina wrote:
          >
          > > Hey guys, i'm new to AJAX and i'm trying to make that good n old
          > > related combo boxes (like, country -> state). Although in my code
          the
          > > ids and names of the combos are dinamycally made (because I have
          10
          > > different combos) well it worked really well on firefox, although,
          > > when I tryed in Internet Explorer 7 it didn't work, here is the
          code:
          > >
          > > function Ajax(uf,n){
          > > var xmlHttp;
          > > var url = "scripts/selecionamun.php?uf="+uf;
          > > var browser=navigator.appName;
          > > alert(n);
          > > if (browser == "Microsoft Internet Explorer") {
          > > try {
          > > xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
          > > }
          > > catch (e) {
          > > xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
          > > }
          > > }else {
          > > xmlHttp=new XMLHttpRequest();
          > > }
          > > xmlHttp.onreadystatechange=function() {
          > > if(xmlHttp.readyState==4) {
          > > document.getElementById(n).innerHTML = xmlHttp.responseText;
          > > alert(document.getElementById(n));
          > > }
          > > }
          > > xmlHttp.open("GET",url,true);
          > > xmlHttp.send(null);
          > > }
          > >
          > > Explaining the alerts:
          > > The first one i put there just to see if he's getting the right
          combo
          > > to populate with data, and it is getting the id right
          > > The second Alert show me the object he is getting, and in Firefox
          it
          > > says [Object HTMLSelectElement] (look like perfect since im doing
          the
          > > code with a select element) and in IE it shows only [object] (i
          think
          > > thats the problem maybe?)
          > >
          > > Well FF puts the data in the box the way it should, although IE
          just
          > > erase what was already writen (it was written --Select--)
          > > If anyone can help I thank you :)
          > >
          > > PS: Im brazilian, so sorry for any kind of mistyping :P and in
          fact
          > > it is not a country -> state box its a State -> city (named UF
          (state)
          > > in the code)
          > >
          > >
          > > ------------------------------------
          > >
          > > Visit http://aiaiai.com for more groups to joinYahoo! Groups Links
          > >
          > >
          > >
          >
          > -D. Israel
          > dan@...
          > http://www.customcodebydan.com
          > AIM: JudoDanIzz
          >
          >
          >
          > [Non-text portions of this message have been removed]
          >
        • Filipe La Ruina
          Sry for double post, but i fund out the problem is relywith IE http://support.microsoft.com/default.aspx?scid=kb;en-us;276228 micrsoft explains tat there is
          Message 4 of 4 , Jun 9, 2008
          • 0 Attachment
            Sry for double post, but i fund out the problem is relywith IE
            http://support.microsoft.com/default.aspx?scid=kb;en-us;276228
            micrsoft explains tat there is actually a problem with IE select and
            innerHtml function =/ (hate IE)
            Solution for those having same problem:
            Wrap select into DIV and change DIV innerHtml (some extra lines of
            code...)

            Try it tomorrow, see ya!

            --- In JavaScript_Official@yahoogroups.com, "Filipe La Ruina"
            <filaruina@...> wrote:
            >
            > In fact the XMLHttpRequet is working ok, since I already put some
            > debugging to see if that is working... there is another problem =/
            > Oh and I've read somewhere that the innerHTML editing dont work on
            > IE7, someone can confirm that?
            >
            > --- In JavaScript_Official@yahoogroups.com, Daniel Israel <dan@>
            > wrote:
            > >
            > >
            > > Just off the top of my head... you should check to see if the
            > > XMLHttpRequest object is available first and use that. IE7 will
            > use
            > > that now instead of an ActiveXObject.
            > >
            > > On Jun 8, 2008, at 11:02 AM, Filipe La Ruina wrote:
            > >
            > > > Hey guys, i'm new to AJAX and i'm trying to make that good n old
            > > > related combo boxes (like, country -> state). Although in my
            code
            > the
            > > > ids and names of the combos are dinamycally made (because I
            have
            > 10
            > > > different combos) well it worked really well on firefox,
            although,
            > > > when I tryed in Internet Explorer 7 it didn't work, here is the
            > code:
            > > >
            > > > function Ajax(uf,n){
            > > > var xmlHttp;
            > > > var url = "scripts/selecionamun.php?uf="+uf;
            > > > var browser=navigator.appName;
            > > > alert(n);
            > > > if (browser == "Microsoft Internet Explorer") {
            > > > try {
            > > > xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
            > > > }
            > > > catch (e) {
            > > > xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
            > > > }
            > > > }else {
            > > > xmlHttp=new XMLHttpRequest();
            > > > }
            > > > xmlHttp.onreadystatechange=function() {
            > > > if(xmlHttp.readyState==4) {
            > > > document.getElementById(n).innerHTML = xmlHttp.responseText;
            > > > alert(document.getElementById(n));
            > > > }
            > > > }
            > > > xmlHttp.open("GET",url,true);
            > > > xmlHttp.send(null);
            > > > }
            > > >
            > > > Explaining the alerts:
            > > > The first one i put there just to see if he's getting the right
            > combo
            > > > to populate with data, and it is getting the id right
            > > > The second Alert show me the object he is getting, and in
            Firefox
            > it
            > > > says [Object HTMLSelectElement] (look like perfect since im
            doing
            > the
            > > > code with a select element) and in IE it shows only [object] (i
            > think
            > > > thats the problem maybe?)
            > > >
            > > > Well FF puts the data in the box the way it should, although IE
            > just
            > > > erase what was already writen (it was written --Select--)
            > > > If anyone can help I thank you :)
            > > >
            > > > PS: Im brazilian, so sorry for any kind of mistyping :P and in
            > fact
            > > > it is not a country -> state box its a State -> city (named UF
            > (state)
            > > > in the code)
            > > >
            > > >
            > > > ------------------------------------
            > > >
            > > > Visit http://aiaiai.com for more groups to joinYahoo! Groups
            Links
            > > >
            > > >
            > > >
            > >
            > > -D. Israel
            > > dan@
            > > http://www.customcodebydan.com
            > > AIM: JudoDanIzz
            > >
            > >
            > >
            > > [Non-text portions of this message have been removed]
            > >
            >
          Your message has been successfully submitted and would be delivered to recipients shortly.