ajax javascript problem with mozilla

 
Post new topic   Reply to topic    Web Design Forum :: Javascript Development
View previous topic :: View next topic  
Author Message
ajithredsmoke



Joined: 09 Sep 2009
Posts: 1
Location: Cochin.India

PostPosted: Wed Sep 09, 2009 5:58 am    Post subject: ajax javascript problem with mozilla Reply with quote
I'm a newbie in programming.
I spent few hours yesterday and today working on a small AJAX page with multiple combo boxes that are populated from the database. I use IE6 99% of the time and I utilize the excellent . I almost done with the page (I’m pretty proud of it too) so I decided to show it to my work buddy. On both IE8 and opera, my beautiful double combo boxes just failed miserably. A part of what I was doing was to populate a double combo box with dynamic data from the database. I created an empty SELECT tag (dynamically via JS), assigned its an ID, made an AJAX request, then populated the empty SELECT tag via the innerHTML with the AJAX response, which is a list of OPTION elements. On IE6, the double combo works so well that I thought it was time wrap up the project. However, on other browsers, the combo box just mysteriously failed to get populated.

First of all, I tried to eliminiate the possibility of my AJAX requests got messed up somewhere. I traced through the flow of the functions and put alert() to assert the responses of the AJAX requests.Everything works fine except the second combo.

Here's the ajax code..


function selected()
{
//alert("entered in function");

var xmlHttp;
var str = document.form1.coursename.value;
var bname = navigator.appName;
var vname = bname + navigator.appVersion;

alert(str);

try
{
//alert(vname);
//explorer 7+,firefox,safari,chrome,opera and others
xmlHttp = new XMLHttpRequest();


}
catch(e)//for IE
{
try
{
//alert("ie6");
//for explorer 6.0
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(e)
{
try
{
//alert("ie>6");
//explorer > 6
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");

}
catch(e)
{
//explorer < 4
alert("Ajax is not supported by your browser");
}
}
}

xmlHttp.onreadystatechange = function()
{alert("entered in state changed");
if(xmlHttp.readystate == 4)
{
document.getElementById("subjectplace").innerHTML = xmlHttp.responseText;//subjectplace is the id of div tag
alert("readystate=4");
}
}
xmlHttp.open("get","mypage.php?q="+str,true);
xmlHttp.send(null);

}


Any Kind of help will be appreciated..
Thanks in advance..
Back to top
View user's profile Send private message Send e-mail Yahoo Messenger
Post new topic   Reply to topic    Web Design Forum :: Javascript Development All times are GMT
Page 1 of 1
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

Powered by phpbb