473,388 Members | 1,213 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

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.onreadystatechange = function(evt)
{
if (httpReq.readyState == 4)
{
if (httpReq.status == 200)
{
getList(httpReq.responseText);
}
}
}
httpReq.open("GET", "http://www.mysite.com", true);
httpReq.send(null);
}catch(ex)
{
Components.utils.reportError(ex);
}
}
function getList(htmlText)
{
for(;;)
{
}
}
Jun 27 '08 #1
5 1677
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.onreadystatechange = function(evt)
* * * * {
* * * * * * if (httpReq.readyState == 4)
* * * * * * {
* * * * * * * * if (httpReq.status == 200)
* * * * * * * * {
* * * * * * * * * * getList(httpReq.responseText);
* * * * * * * * }
* * * * * * }
* * * * }

* * * * httpReq.open("GET", "http://www.mysite.com", true);
* * * * httpReq.send(null);
* * }catch(ex)
* * {
* * * * Components.utils.reportError(ex);
* * }

}

function getList(htmlText)
{
* * for(;;)
* * {
* * }

}- Hide quoted text -

- Show quoted text -
actually, let me post the correct code. I do some stuff in the for
loop.
Jun 27 '08 #2
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.onreadystatechange = function(evt)
{
if (httpReq.readyState == 4)
{
if (httpReq.status == 200)
{
getList(httpReq.responseText);
}
}
}

httpReq.open("GET", "http://www.mysite.com", true);
httpReq.send(null);
}catch(ex)
{
Components.utils.reportError(ex);
}

}

function getList(htmlText)
{
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
Jun 27 '08 #3
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(htmlText)
{
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
--
Jun 27 '08 #4
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(htmlText)
{
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...
Jun 27 '08 #5
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...
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Colin Steadman | last post by:
I have created a function to kill all session variables that aren't in a safe list. This is the function - Sub PurgeSessionVariables For Each Item In Session.Contents Select Case Trim(Item)...
3
by: Chris Geerdink | last post by:
combo with PHP. what is wrong with the Javascript? else { include("mysql.php"); $query1 = mysql_query("INSERT INTO gbook (naam, email, text) VALUES ('".$_POST."', '".$_POST."',...
4
by: asdf | last post by:
Hello! Can someone tell me whats wrong with this piece of code: Option Compare Database Option Explicit Sub retrieve() Dim rst As ADODB.Recordset Dim i As Integer
1
by: aa | last post by:
When I am reading from local disk (d:), everithing is OK, but then I am reading from map disk I am geting the this error. Whats wrong. Thanks Server Error in '/Extra' Application....
3
by: mahsa | last post by:
Hi do you know whats wrong with this code? <asp:HyperLink id="HLink_Help" runat="server" NavigateUrl='<%# "javascript:window.open('comments.aspx?id=1,width=500,height=600, scrollBars=yes');"...
4
by: blah | last post by:
Hello everyone, Ive been trying to get my application to "click" on a button in another application using SendMessage, Ive gotten this far but Im not sure whats wrong with this code, here is the...
7
by: Mike Barnard | last post by:
It's a simple test... VERY SIMPLE. But... In an external stlyesheet some attributes don't show. With the same styles cut and pasted to the test internally it works as expected. Anyone tell...
1
by: Abubakar | last post by:
Hi, In my application, Some of my thread gets stuck somewhere. The vs2k5 debugging "Thread" window shows that stuck thread and I can I dentify it. In its Name column the following text is...
5
by: islayer | last post by:
can someone tell me what is wrong with the bold code? i am just learning perl. the program should create a perl file with a random name (5 letters, followed by a number), but the name is always just...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.