473,394 Members | 1,183 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,394 software developers and data experts.

Stack overflow Error

This is recursive function , once result displayed on browser i am calling tht function again for updation

Expand|Select|Wrap|Line Numbers
  1. function retrieveURL(url) 
  2. {
  3. if (window.ActiveXObject) { // Working on IE 
  4. req = new ActiveXObject("Microsoft.XMLHTTP");
  5. if (req) { 
  6. req.onreadystatechange = processStateChange;
  7. req.open("GET", url, true); 
  8. req.send();
  9. }
  10. }
  11. }
  12. function processStateChange() {
  13. if (req.readyState == 4) { 
  14. var characters = document.getElementById("characters"); 
  15. var result = req.responseText; 
  16. if(result.length > 50)
  17. {
  18. characters.value=result;
  19. result=null;
  20. req=null;
  21. retrieveURL('CPUutil.do'); 
  22. }
  23. }
  24.  
I am unable to understand why i am getting stack overflow exception, sometimes it'll work good , is this is because of cache problem ,, ?
while debugging with alert boxes .i'll came to know that if i'll put multiple alert boxes it will work fine,
Jun 17 '09 #1
8 2843
acoder
16,027 Expert Mod 8TB
For recursion to work, you need a base point (to end the recursion) which you don't have, so the stack will obviously overflow.
Jun 17 '09 #2
Thanks a lot for your reply,
But I want this page to be continuously refresh with updated results. I want to resubmit same request again n again but it is not going on specified url .
Jun 17 '09 #3
acoder
16,027 Expert Mod 8TB
Then why not use setInterval() to make regular requests?
Jun 17 '09 #4
Response time form server is not definite.. though it is synchronized on server side ,i don wan to increase thread waiting pool .only way to make request is when response arrives
Jun 17 '09 #5
acoder
16,027 Expert Mod 8TB
Either make an Ajax object which deals with all requests, or use Comet/reverse Ajax where the data is "pushed" from the server.
Jun 17 '09 #6
actully this is my first Ajax based page n i don know how to create AjaxObject which deals with all requests....could u please tell me (in short)how to create ajax object or how to implement Comet Ajax..i'll be vry thnkful 2 u ...
Jun 18 '09 #7
Now this code is working fine without throwing "stack overflow" exception on my local machine, but after deploying it on IBM web sphere server it is throwing same exception (Stack Overflow)

Expand|Select|Wrap|Line Numbers
  1. var xmlhttp;
  2. function retrieveURL(url) 
  3. {
  4. xmlhttp=null;
  5. if (window.XMLHttpRequest)
  6.   {// code for Firefox, Mozilla, IE7, etc.
  7.   xmlhttp=new XMLHttpRequest();
  8.   }
  9. else if (window.ActiveXObject)
  10.   {// code for IE6, IE5
  11.   xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  12.   }
  13. if (xmlhttp!=null)
  14.   {
  15.   xmlhttp.onreadystatechange = processStateChange;
  16.   xmlhttp.open("GET",url,true);
  17.   xmlhttp.send(null);
  18.   }
  19. else
  20.   {
  21.   alert("Your browser does not support Ajax Objects.");
  22.   }
  23. }
  24.  
  25.  
  26. function processStateChange() {
  27.  
  28. if (xmlhttp.readyState==4)
  29.   {// 4 = "loaded"
  30.   if (xmlhttp.status==200)
  31.     { // Complete        
  32.              var characters = document.getElementById("characters");            
  33.              var result = xmlhttp.responseText;                     
  34.              if(result.length > 50)
  35.              {        
  36.              characters.value=result;
  37.              result=null;            
  38.             }
  39.         retrieveURL('CPUutil.do');                        
  40.          }
  41.   }
  42. }
Jun 18 '09 #8
acoder
16,027 Expert Mod 8TB
Here's one simple example. There are quite a few more if you search. It should give you an idea. You can then try a new request every second. If the first one is still in progress, it will not make a new request. Once it's complete, it will make the new request.
Jun 18 '09 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: ip4ram | last post by:
I am quite puzzled by the stack overflow which I am encountering.Here is the pseudocode //define stack structure //function operating on stack void my_stack_function( function parameters) {...
7
by: Aguilar, James | last post by:
Hello all, To begin, yes, this -is- a homework assignment. However, it is for my Algorithms class, and my instructor has given us explicit permission to use "expert" groups like newsgroups, so...
13
by: Will Pittenger | last post by:
I have a Control derived class. When the parent of the control changes the control's Location property, the stack overflows. I have not found a way to find out what was on the stack when it does...
19
by: Jim | last post by:
I have spent the past few weeks designing a database for my company. The problem is I have started running into what I believe are stack overflow problems. There are two tab controls on the form...
5
by: jbix | last post by:
We have a stack overflow happening. We are NOT doing any recusion. We do have an object being created in Global that is being handed the Context (which I assume is specific to the request thread). ...
2
by: Ali | last post by:
Hi, I got stack overflow errors while using an unmanaged dll from managed c# application. When i use editbin.exe to increase stack size of app , it works. Is there a way to increase stack size of...
6
by: Daz | last post by:
Hi everyone! It is indeed, once again time for me to ask another stupid question. I have been searching around on the net for quite a while, and can't find anything that explains 'exactly'...
3
by: capes | last post by:
Hi, I have a structure called Tissue and I use it in a matrix like this: vector < vector < Tissue* tissueArray(cRows); This whole function works great for a matrix size of 2X2 to 15X15....
12
by: Geoff Cox | last post by:
Hello, Some one is getting the "stack overflow" error message when using a Javascript program which I wrote when using Internet Explorer but not when using Mozilla. Any ideas as to how I...
5
by: moondaddy | last post by:
I'm trying to serialize some xaml elements using the XamlWriter and I'm getting a stack overflow error because the elements have some public properties which get called about a million ( a lot)...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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.