Ajax request delegiert die Rückgabe nicht

NetBull

Erfahrenes Mitglied
Hi,

nach langer Zeit muss ich mal wieder was mit JavaScript lösen und gleich ein Problem mit der Schreibweise, wie ich vermute.

Mein Problem ist vermutlich hier:
Code:
function onTestCallBack(){
function doResponse(test){
// do blabla
}
}
Denn ich möchte das der CallBack direkt in die doResponse methode des onTestCallBack objects geht.

Der Aufruf 'requestFromServer("testClass", "testMethod", par, onTestCallBack);' ruft dies auf:
Code:
function requestFromServer(aClass, aMethod, aParameters, aCallBack, aIsAsyncron=false){		
	XmlRequest = initiateAjaxRequest(aCallBack);/* initializes the request*/
	XmlRequest.open("post", gAjaxResponseClassPath, aIsAsyncron); //*** if true request is a-syncron******
	XmlRequest.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	aRequestArguments = null;
	XmlRequest.send(aRequestArguments);/* arguments include the method wich is called from php do create the response */
	
	return XmlRequest;
}

was dann einen request wie folgt auslöst:
Code:
function initiateAjaxRequest(aCallBackFunction)
{//*** ajax request, valid for all servers		
	var XmlRequest=null;		
	try{// most browsers, also newer IE-browsers
		XmlRequest = new XMLHttpRequest();
    }
    catch (e){
        try{// older brwowsers 	
        	XmlRequest = new ActiveXObject("Msxml2.XMLHTTP");	
        } 
        catch (e){
            try{// older IE-browsers
                XmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
            } 
            catch (failed){//*** if all where failing, return nothing
                XmlRequest = null;
            }
        }  
    }
    
    // attach a ready-state event to the xmlRequest
    XmlRequest.onreadystatechange = function(aReturnObject){	        
    	switch(XmlRequest.readyState){
            case 4:
                if(XmlRequest.status!=200)//*** on error states
                	XmlRequest.responseText = "ERROR #"+XmlRequest.status+" detected! Could not get a response from Server!";
                if(XmlRequest.status==200){//*** on good states
                	/* declare and initiate a new call back object to work with the xml response */
                	//mAjaxCallBackObject = new ajaxCallBackObject(XmlRequest);	                	
                	aCallBackFunction.doResponse(mAjaxCallBackObject);
                }
                break;
        }
    };	    
    return XmlRequest;
}

Aber wie ich es auch versuche, die Fehlermeldung lautet:
Code:
ReferenceError: mAjaxCallBackObject is not defined
aCallBackFunction.doResponse(mAjaxCallBackObject);

Grüße aus dem Rheinland...
deAndro
 

Neue Beiträge

Zurück