I hav an intersting issue with the below JS code, works in IE and Chrome but not in FF. The ajax call brings back the results which I can see with Firebug. The idea is that the function gets passed the DIV parameter and checks to see what that is:
object (usually a div);
another function (to pass the results to) or
a string which gets returned to the calling function
So the only thing that doesn't seem to be executing is the div branch where the results are innerHTML'd into the div that I pass in. Am I doing something wrong in the test for the DIV with regard to FF?
Bastien
I wish my computer would do what I want it to do,
instead of what I tell it to do...
object (usually a div);
another function (to pass the results to) or
a string which gets returned to the calling function
So the only thing that doesn't seem to be executing is the div branch where the results are innerHTML'd into the div that I pass in. Am I doing something wrong in the test for the DIV with regard to FF?
Code:
function Ajax(url, data, div, Asynch)
{
// url string url of the page to activate
// data string data to be passed to the server
// div object div name as object, function name to be have the result passed to when returned, empty string to return the response to the calling function
var objAjax = getAjaxObject();
if (objAjax != null){
objAjax.onreadystatechange = function(){
if (objAjax.readyState == 4) {
if (objAjax.status == 200) {
strResponse = objAjax.responseText;
switch (typeof(div))
{
case "object":
if (div.style.display == 'none'){ div.style.display = 'inline'; }
div.innerHTML = strResponse;
break;
case "function":
div(strResponse);
break;
case "string":
return strResponse;
break;
}//end switch
objAjax = null;
}else{
alert("[" + objAjax.status + "] Error: " + objAjax.reponseText);
}//end if(objAjax.status == 200)
}//end if(objAjax.readyState == 4)
}//end anon function
sendRequest(objAjax, "POST", url, Asynch, data);
}//(objAjax != null)
}//end function
Bastien
I wish my computer would do what I want it to do,
instead of what I tell it to do...