...

View Full Version : Internet Explorer - XMLHTTPRequest problem



mauroalberti
03-03-2006, 04:05 PM
Hello everyone,

I'm currently trying to add some AJAX functionality to the tree2 JSF-component from the Apache MyFaces project (i. e. if the

user clicks on some node of the tree component, then not the whole tree is to be rendered again but just the part of the tree

which has actually changed).

Using Mozilla as browser everything works fine, but if IE is used I'm facing the following problem:

If I click on the [-] box next to an expanded node, nothing happens (of course, normally the node should be closed).


This is the AJAX part of the code on my JSP page:

<script type="text/javascript">
<!--
var clickedNodeID;

var req;

function ajaxtest(treenodeid){

//req = null;

if (window.XMLHttpRequest) {
req = new XMLHttpRequest();
}
else if (window.ActiveXObject) {
req = new ActiveXObject("Microsoft.XMLHTTP");
}

if (req.readyState != 0) {
req.abort();
}


clickedNodeID = treenodeid;

var url = "webdeskAjax.faces?clickedNodeID="+ treenodeid;

// send request to the server
if (req != null) {
req.open("GET", url, true);
req.onreadystatechange = processAjaxTreeResponse;
req.send(null);
}

}

function processAjaxTreeResponse() {
if (req.readyState == 4){
//process only if OK
if (req.status == 200) {
if(req.responseText==null) {
hidePopup();
}
else {
parseAjaxResponse(req.responseText);

}
}
}


}


function parseAjaxResponse(result){


var divnode = document.getElementById(clickedNodeID + ":divid");

divnode.innerHTML = result;

alert(result);


}


//-->
</script>


The variables req and clickedNodeID contain the XMLHTTPRequest object respevtively the ID of the node which has been lastly

clicked.

The parseAjaxResponse method determines a certain div element and adds the content being sent from the server to this element.

The alert statement has been added merely for testing purposes (as my MS-Debugger crashes every time I'm trying to move a single

step further- anyone in here made similar experiences with the application???): every time I click on the [-] box the content

that is added to the div element is equal to the content that has been saved in the element before the user action. The point

is, that the server has not been contacted (I've registered a PhaseListener to my FacesContext) so I absolutely do not know

where the content comes from...

Anyone got any advice what could be the reason for that odd behavior??

Thanks a lot,

Alex

KC-Luck
03-06-2006, 07:24 PM
does the alert fire?
does it have content?

also, the test for req.abort() should be done before you attempt to reset that req to another instance of XMLHTTP



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum