Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Weird JS thing

Weird JS thing

Scheduled Pinned Locked Moved The Lounge
questionjavascripthelp
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    BobJanova
    wrote on last edited by
    #1

    I think it's fair to post this here because I'm not asking a question, just airing for your amusement, even if it's code related. I've just been doing some work on a web (well, intranet) system, and we use AJAX to populate a dropdown based on other selections on the form. When a first option is selected, we request a list of days that it is valid on for the user to select one, and the AJAX response is something like

    Y
    1|Monday
    3|Wednesday
    4|Thursday

    ... where the first line is a flag to set a checkbox. My AJAX response code included something similar to the following:

    var lines = link.responseText.split('\n');

    // ... some stuff for dropdown

    var show = 'Y' == lines[0][0]; // (1)
    checkboxDiv.style.display = show ? '' : 'none';

    This worked fine, cross browser compatibility was no problem, even IE could cope with it. We deployed the system ... and suddenly we were getting weird behaviour with the checkbox not appearing. After a bit of digging, I tracked it down to line (1). On the live system, I had to use

    var show = 89 == lines[0].charCodeAt(0); // (1a)

    In the local system, and in all other browsers, even if I set the AJAX target to the live system's URL, it worked fine both ways. I never did work out what the difference could be. Computers, huh. Can't trust them. :~

    R 1 Reply Last reply
    0
    • B BobJanova

      I think it's fair to post this here because I'm not asking a question, just airing for your amusement, even if it's code related. I've just been doing some work on a web (well, intranet) system, and we use AJAX to populate a dropdown based on other selections on the form. When a first option is selected, we request a list of days that it is valid on for the user to select one, and the AJAX response is something like

      Y
      1|Monday
      3|Wednesday
      4|Thursday

      ... where the first line is a flag to set a checkbox. My AJAX response code included something similar to the following:

      var lines = link.responseText.split('\n');

      // ... some stuff for dropdown

      var show = 'Y' == lines[0][0]; // (1)
      checkboxDiv.style.display = show ? '' : 'none';

      This worked fine, cross browser compatibility was no problem, even IE could cope with it. We deployed the system ... and suddenly we were getting weird behaviour with the checkbox not appearing. After a bit of digging, I tracked it down to line (1). On the live system, I had to use

      var show = 89 == lines[0].charCodeAt(0); // (1a)

      In the local system, and in all other browsers, even if I set the AJAX target to the live system's URL, it worked fine both ways. I never did work out what the difference could be. Computers, huh. Can't trust them. :~

      R Offline
      R Offline
      Rage
      wrote on last edited by
      #2

      Could it be that lines[0][0] returned a longer string on the target system (carriage return ?) In this case, the code (1) would not work anymore, whereas code (1a) would, though being apparently identical.

      B 1 Reply Last reply
      0
      • R Rage

        Could it be that lines[0][0] returned a longer string on the target system (carriage return ?) In this case, the code (1) would not work anymore, whereas code (1a) would, though being apparently identical.

        B Offline
        B Offline
        BobJanova
        wrote on last edited by
        #3

        Something like that would make sense except that the same browser (I think it was IE8) would act differently depending on whether the host URL (not even the AJAX lookup one) was localhost/... or deployed_domain.example.com/... . Edi: the same browser on the same machine, i.e. you could set up two tabs in the same browser instance pointing at the two URLs and it would work for one and not the other.

        R A 2 Replies Last reply
        0
        • B BobJanova

          Something like that would make sense except that the same browser (I think it was IE8) would act differently depending on whether the host URL (not even the AJAX lookup one) was localhost/... or deployed_domain.example.com/... . Edi: the same browser on the same machine, i.e. you could set up two tabs in the same browser instance pointing at the two URLs and it would work for one and not the other.

          R Offline
          R Offline
          Rage
          wrote on last edited by
          #4

          Oh, Internet Explorer. And you still wonder...

          1 Reply Last reply
          0
          • B BobJanova

            Something like that would make sense except that the same browser (I think it was IE8) would act differently depending on whether the host URL (not even the AJAX lookup one) was localhost/... or deployed_domain.example.com/... . Edi: the same browser on the same machine, i.e. you could set up two tabs in the same browser instance pointing at the two URLs and it would work for one and not the other.

            A Offline
            A Offline
            Andy Brummer
            wrote on last edited by
            #5

            What were the different servers? Is there a header that is forcing the browser into a different mode?

            Curvature of the Mind now with 3D

            B 1 Reply Last reply
            0
            • A Andy Brummer

              What were the different servers? Is there a header that is forcing the browser into a different mode?

              Curvature of the Mind now with 3D

              B Offline
              B Offline
              BobJanova
              wrote on last edited by
              #6

              Local was a Visual Studio local ASP web server. Deployment was some sort of IIS. So I guess it must be something like this. I don't care enough to find out now, since my involvement with this application is over anyway :p

              A 1 Reply Last reply
              0
              • B BobJanova

                Local was a Visual Studio local ASP web server. Deployment was some sort of IIS. So I guess it must be something like this. I don't care enough to find out now, since my involvement with this application is over anyway :p

                A Offline
                A Offline
                Andy Brummer
                wrote on last edited by
                #7

                Yeah, IE can do some weird crap based on URL. For intranet zone sites I think it defaults to IE6 compatibility.

                Curvature of the Mind now with 3D

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups