function breaks when run too fast?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Angel

    function breaks when run too fast?

    Hi,

    I have a pretty wierd situation. I have a javascript function that
    runs when I submit a page. The onsubmit code does quite a bit - it
    goes through a big textarea and replaces tabs with spaces,
    inserts/removes line breaks...it uses regular expressions to convert
    textarea content into somethign that can be sent to a mainframe
    application.

    Here's the problem: Sometimes special characters are pasted into the
    text area from Word. Then, the submit code seems to go wrong - it
    jumbles the content and some of the data is lost. I started adding
    alerts in various places in the code to try and see where it was going
    wrong. But it seems that by placing the alerts in the function, it
    slows it down... and the error goes away!

    It seems as though the code is going too fast and getting confused.
    ....but that doesn't really make sense to me. Has anyone ever
    experienced illogical breaks like this? Any suggestions?

    Thanks in advance!
  • Thomas 'PointedEars' Lahn

    #2
    Re: function breaks when run too fast?

    John Angel wrote:[color=blue]
    > I have a pretty wierd situation. I have a javascript function that
    > runs when I submit a page. The onsubmit code does quite a bit [...]
    > Here's the problem: Sometimes special characters are pasted into the
    > text area from Word. Then, the submit code seems to go wrong - it
    > jumbles the content and some of the data is lost. [...][/color]

    URL?


    PointedEars

    Comment

    • John Angel

      #3
      Re: function breaks when run too fast?

      Thomas 'PointedEars' Lahn <PointedEars@nu rfuerspam.de> wrote in message news:<410E895A. 5020503@Pointed Ears.de>...[color=blue]
      > John Angel wrote:[color=green]
      > > I have a pretty wierd situation. I have a javascript function that
      > > runs when I submit a page. The onsubmit code does quite a bit [...]
      > > Here's the problem: Sometimes special characters are pasted into the
      > > text area from Word. Then, the submit code seems to go wrong - it
      > > jumbles the content and some of the data is lost. [...][/color]
      >
      > URL?
      >
      >
      > PointedEars[/color]

      Unfortunately, this is part of a large, internal web application. I
      guess I'm just wondering whether or not it's possible for javascript
      (In IE6/xp) to get "ahead of itself" as it seems to.

      Comment

      • John Angel

        #4
        Re: function breaks when run too fast?

        Thomas 'PointedEars' Lahn <PointedEars@nu rfuerspam.de> wrote in message news:<410E895A. 5020503@Pointed Ears.de>...[color=blue]
        > John Angel wrote:[color=green]
        > > I have a pretty wierd situation. I have a javascript function that
        > > runs when I submit a page. The onsubmit code does quite a bit [...]
        > > Here's the problem: Sometimes special characters are pasted into the
        > > text area from Word. Then, the submit code seems to go wrong - it
        > > jumbles the content and some of the data is lost. [...][/color]
        >
        > URL?
        >
        >
        > PointedEars[/color]

        Unfortunately, this is part of a large, internal web application. I
        guess I'm just wondering whether or not it's possible for javascript
        (In IE6/xp) to get "ahead of itself" as it seems to.

        Comment

        • rf

          #5
          Re: function breaks when run too fast?

          John Angel
          [color=blue]
          > Unfortunately, this is part of a large, internal web application. I
          > guess I'm just wondering whether or not it's possible for javascript
          > (In IE6/xp) to get "ahead of itself" as it seems to.[/color]

          When I drive my car too fast it rattles. Can you tell me what is wrong?

          Oh, you want to see the car? Well, no, unfortunately you cant. It's locked
          in the garage.

          --
          Cheers
          Richard.



          Comment

          • Lee

            #6
            Re: function breaks when run too fast?

            John Angel said:
            [color=blue]
            >[...]
            >But it seems that by placing the alerts in the function, it
            >slows it down... and the error goes away![/color]

            Yes, that happens. Sometimes it seems to be a bug in the
            browser that requires a change in state from code execution
            to event processing before a change takes place. Other cases
            can be explained by the fact that some method calls return
            before the task (opening a window, for example) is completely
            finished.

            It's likely that at least one person reading this has
            experienced your problem, but we would need to see an example.

            We don't need to see the whole project.
            Create a small test case that demonstrates the problem.
            I'm particularly interested in seeing how you invoke the code
            that's causing trouble.

            Comment

            • Grant Wagner

              #7
              Re: function breaks when run too fast?

              John Angel wrote:
              [color=blue]
              > Hi,
              >
              > I have a pretty wierd situation. I have a javascript function that
              > runs when I submit a page. The onsubmit code does quite a bit - it
              > goes through a big textarea and replaces tabs with spaces,
              > inserts/removes line breaks...it uses regular expressions to convert
              > textarea content into somethign that can be sent to a mainframe
              > application.
              >
              > Here's the problem: Sometimes special characters are pasted into the
              > text area from Word. Then, the submit code seems to go wrong - it
              > jumbles the content and some of the data is lost. I started adding
              > alerts in various places in the code to try and see where it was going
              > wrong. But it seems that by placing the alerts in the function, it
              > slows it down... and the error goes away![/color]

              That is known as a "heisenbug" :
              <url: http://info.astrian.net/jargon/terms/h/heisenbug.html />
              <url: http://c2.com/cgi/wiki?HeisenBug />
              <url: http://www.wordspy.com/words/heisenbug.asp />
              [color=blue]
              > It seems as though the code is going too fast and getting confused.
              > ...but that doesn't really make sense to me. Has anyone ever
              > experienced illogical breaks like this? Any suggestions?[/color]

              It seems unlikely that the code is "going too fast". It is, as Lee pointed
              out, more likely an issue with the way you invoke your code.

              Also, given the fact that you mention "special characters", I'd ensure
              your code is either unicode compatible, or can deal with unicode
              characters properly, either by rejecting them outright, or converting them
              into something that you can actually submit (by modding the character code
              with 256 for example).

              --
              Grant Wagner <gwagner@agrico reunited.com>
              comp.lang.javas cript FAQ - http://jibbering.com/faq


              Comment

              • Thomas 'PointedEars' Lahn

                #8
                Re: function breaks when run too fast?

                John Angel wrote:[color=blue]
                > Thomas 'PointedEars' Lahn <PointedEars@nu rfuerspam.de> wrote [...]:[color=green]
                >> John Angel wrote:[color=darkred]
                >>> [...] I have a javascript function that runs when I submit a page.
                >>> The onsubmit code does quite a bit [...] Here's the problem:
                >>> Sometimes special characters are pasted into the text area from Word.
                >>> Then, the submit code seems to go wrong - it jumbles the content and
                >>> some of the data is lost. [...][/color]
                >>
                >> URL?
                >> [...][/color]
                >
                > Unfortunately, this is part of a large, internal web application. I guess
                > I'm just wondering whether or not it's possible for javascript (In
                > IE6/xp) to get "ahead of itself" as it seems to.[/color]

                You could post relevant snippets of your code as well.


                PointedEars

                P.S.
                Please read <http://netmeister.org/news/learn2quote.htm l> regarding
                the attribution _line_ and other recommended quoting practices.

                Comment

                Working...