Solved

What could cause an ajax request (using cfajaxproxy) to hang?

Posted on 2008-10-20
2
460 Views
Last Modified: 2012-06-21
I'm having really inconsistent results with cfajaxproxy, whereby it seems to sometimes hang and ultimately crash the browser. Below is an example template function, so that you can see what the remote functions i'm writing look like, although this does work in 99% of the cases i have one instance inwhich it just hangs indefinately. It is completely bizarre since the log output just before "when it should return" is written out (and so the code block's contents are irrelevant), but yet the browser does not seem to recognise or i suspect receive an end-of-transmission message from the browser. The contents of the code-block does however influence whether or not the function returns, even tho the log outputs IN ALL CASES the final log message WITHOUT then returning!?

My question is has anyone found this hanging problem, i know it's not related to the code being executed hanging since the final log messages are outputed, and it's not due to an error being thrown within the code block since any error should be caught and returned as a message response. The javascript is alerting() all response text in all cases.

Has anyone seen this, and can anyone suggest any reason for this apparent hanging?

BTW. Using firebug it tells me that the javascript is not responding, or waiting for a response, and points me to inside the loop in figure b) in the attached code. Is this not indicating that it's waiting for a response from the server? .. any why does it not receive it??

This problem has been driving me nuts so any help much appreciated!
a)
 

<CFFUNCTION name="performThis" access="remote" returnFormat="plain">

	<CFARGUMENT name="requestData" type="string">

	// code here
 

         <CFSET SESSION.log.debug("I am here")>
 

	<CFRETURN "OK">	

	<CFCATCH type="any">

                  <CFSET SESSION.log.debug("Some error")>

		<CFRETURN "Error-#cfcatch.message#">

	</CFCATCH>

	</CFTRY>

</CFFUNCTION>
 

b)

[CFIDE/scripts/ajax/package/cfajax.js -CF8]
 

$X.processResponse=function(req,_270){

	var _271=true;

	for(var i=0;i<req.responseText.length;i++){

		var c=req.responseText.charAt(i);

		_271=(c==" "||c=="\n"||c=="\t"||c=="\r");

		if(!_271){

			break;

		}

	}

... etc

Open in new window

0
Comment
Question by:paddycobbett
2 Comments
 
LVL 27

Accepted Solution

by:
azadisaryev earned 500 total points
ID: 22759439
really hard to say what may be wrong from just the code you posted...
but to rule out some possible issues:

1) after all <cfargument ..> tags in your function, add this:
<cfset var fResult = "OK">
1.1) make sure all variables you create in your function are properly var'd to rule out any variable substitution
2) get rid of <CFRETURN "OK"> line
3) change your <CFRETURN "Error-#cfcatch.message#"> line to:
<CFSET fResult = "Error-" & cfcatch.message>
4) add <cfreturn fResult> as the last line in your function, after your </CFTRY>

the 'hanging' of an ajax request is usually due to some code error, so it is likely that 1% of the time some condition is met that causes an error in your code to surface...

you can also try adding ?cfdebug to the url to enable ajax debugger - it may give you some info as to what is the problem...

if you care to post more of your code, including your code that calls your function, it may help us help you further.

hth
0
 
LVL 1

Author Comment

by:paddycobbett
ID: 22827542
Sure enough it did turn out to be related to application logic. It was that each ajax call as a side effect wrote out a large text file. What threw me off was that i wrote out a time stamp before and after the writing of the large text file, and the time difference was less than a second, and sure enough it was pretty instant the updating of the file since (having a text editor with the file opened) it notifyed me of a change to the file (that it had open) almost instantly. It appears to just hang after having written the file out (for up to 20 seconds!), although when i remove the writing out of the file sure enough the response time was verging instant. I thought that perhaps the now() function wasn't accurate, but surely it would update itself atleast after each few seconds!? Any ideas as to the cause of this bizarre inconsistency?
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Select data from dynamically created table... 4 42
Ajax control editor 4 63
code conversion assistance required 1 30
delete database record with modal 21 81
Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now