Advertisement

07.24.2008 at 09:11AM PDT, ID: 23592641
[x]
Attachment Details

Determine AJAX call success

Asked by Jester_48 in Asynchronous Javascript and XML (AJAX)

I have a basic ajax call to a processing page, see code below, how do i get a retunr value form the call to detemine succces or failure?

something lie
if(postData ('/AJAXContent/v_setForwardToExt.cfm' ,'baseExt='+nKey+'&sendExt='+nForward+'&currentExt='+nCurrent)){
do this code block
}

but any check always shows undefined, even tho i can see that teh DB was updated

ThanksStart Free Trial
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
function postData(url,nvPairs,fn){
	var xmlHttp;
	try	{  // Firefox, Opera 8.0+, Safari  
		xmlHttp=new XMLHttpRequest();  
	}catch (e) {  // Internet Explorer  
		try{    
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");    
		}catch (e){    
			try{      
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");      
			}catch (e){      
				alert("Your browser does not support AJAX!");      
				return false;      
			}    
		}  
	}
  
  
  	xmlHttp.onreadystatechange=function(){
   		 if(xmlHttp.readyState==4){
		 	if(fn){
      			eval(fn)(trim(xmlHttp.responseText));
				
			}
			return(trim(xmlHttp.responseText));
     	}
    } //end anonymous function
	
  	xmlHttp.open("POST",url,true);
  	xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
    xmlHttp.send(nvPairs);
}
[+][-]07.24.2008 at 10:29AM PDT, ID: 22081502

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 11:38AM PDT, ID: 22082165

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]07.24.2008 at 04:22PM PDT, ID: 22084614

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Asynchronous Javascript and XML (AJAX)
Sign Up Now!
Solution Provided By: hielo
Participating Experts: 2
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_EXPERT_20070906