Whats wrong with this code?

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

    Whats wrong with this code?

    This issue is driving me nuts and not able to figure out whats wrong.
    I've this code in my firefox extension. Firefox always hangs and
    reports the script is busy.

    if I introduce a break statement in the for(;;) loop below, then
    no issue.

    Any help would be appreciated!

    function getStuff()
    {
    try
    {
    httpReq = new XMLHttpRequest( );


    httpReq.onready statechange = function(evt)
    {
    if (httpReq.readyS tate == 4)
    {
    if (httpReq.status == 200)
    {
    getList(httpReq .responseText);
    }
    }
    }


    httpReq.open("G ET", "http://www.mysite.com" , true);
    httpReq.send(nu ll);
    }catch(ex)
    {
    Components.util s.reportError(e x);
    }
    }


    function getList(htmlTex t)
    {
    for(;;)
    {
    }
    }
  • hiqu

    #2
    Re: Whats wrong with this code?

    On Jun 12, 9:54 am, hiqu <hiqul...@gmail .comwrote:
    This issue is driving me nuts and not able to figure out whats wrong.
    I've this code in my firefox extension. Firefox always hangs and
    reports the script is busy.
    >
    if I introduce a break statement in the for(;;) loop below, then
    no issue.
    >
    Any help would be appreciated!
    >
    function getStuff()
    {
        try
        {
            httpReq = new XMLHttpRequest( );
    >
            httpReq.onready statechange = function(evt)
            {
                if (httpReq.readyS tate == 4)
                {
                    if (httpReq.status == 200)
                    {
                        getList(httpReq .responseText);
                    }
                }
            }
    >
            httpReq.open("G ET", "http://www.mysite.com" , true);
            httpReq.send(nu ll);
        }catch(ex)
        {
            Components.util s.reportError(e x);
        }
    >
    }
    >
    function getList(htmlTex t)
    {
        for(;;)
        {
        }
    >
    >
    >
    }- Hide quoted text -
    >
    - Show quoted text -
    actually, let me post the correct code. I do some stuff in the for
    loop.

    Comment

    • Erwin Moller

      #3
      Re: Whats wrong with this code?

      hiqu schreef:
      On Jun 12, 9:54 am, hiqu <hiqul...@gmail .comwrote:
      >This issue is driving me nuts and not able to figure out whats wrong.
      >I've this code in my firefox extension. Firefox always hangs and
      >reports the script is busy.
      >>
      >if I introduce a break statement in the for(;;) loop below, then
      >no issue.
      >>
      >Any help would be appreciated!
      >>
      >function getStuff()
      >{
      > try
      > {
      > httpReq = new XMLHttpRequest( );
      >>
      > httpReq.onready statechange = function(evt)
      > {
      > if (httpReq.readyS tate == 4)
      > {
      > if (httpReq.status == 200)
      > {
      > getList(httpReq .responseText);
      > }
      > }
      > }
      >>
      > httpReq.open("G ET", "http://www.mysite.com" , true);
      > httpReq.send(nu ll);
      > }catch(ex)
      > {
      > Components.util s.reportError(e x);
      > }
      >>
      >}
      >>
      >function getList(htmlTex t)
      >{
      > for(;;)
      > {
      > }
      >>
      >>
      >>
      >}- Hide quoted text -
      >>
      >- Show quoted text -
      >
      actually, let me post the correct code. I do some stuff in the for
      loop.
      What is your question?
      I am afraid I cannot follow your line of thought at all. :-/

      Regards,
      Erwin Moller

      Comment

      • =?ISO-8859-1?Q?=22=C1lvaro_G=2E_Vicario=22?=

        #4
        Re: Whats wrong with this code?

        hiqu escribió:
        function getStuff()
        {
        try
        {
        httpReq = new XMLHttpRequest( );
        Since httpReq is global, every time you getStuff() you'll destroy any
        other AJAX call that may be executing. Is that the desired effect?

        function getList(htmlTex t)
        {
        for(;;)
        {
        }
        }
        Well, this is pretty obvious xD



        --
        -- http://alvaro.es - Álvaro G. Vicario - Burgos, Spain
        -- Mi sitio sobre programación web: http://bits.demogracia.com
        -- Mi web de humor al baño María: http://www.demogracia.com
        --

        Comment

        • GArlington

          #5
          Re: Whats wrong with this code?

          On Jun 12, 5:54 pm, hiqu <hiqul...@gmail .comwrote:
          This issue is driving me nuts and not able to figure out whats wrong.
          I've this code in my firefox extension. Firefox always hangs and
          reports the script is busy.
          >
          if I introduce a break statement in the for(;;) loop below, then
          no issue.
          <snap>
          >
          function getList(htmlTex t)
          {
          for(;;)
          {
          }
          >
          }
          The above is never ending loop, this is an equivalent of telling your
          CPU to do nothing (NOP) but be BUSY all the time...

          Comment

          • GArlington

            #6
            Re: Whats wrong with this code?

            On Jun 12, 6:10 pm, hiqu <hiqul...@gmail .comwrote:
            On Jun 12, 9:54 am, hiqu <hiqul...@gmail .comwrote:
            >
            <snap>
            >
            actually, let me post the correct code. I do some stuff in the for
            loop.
            Please do (post the correct code), because the posted code does
            EXACTLY what you can expect it to do - hangs you machine...

            Comment

            Working...