Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Ajax + FF = :), Ajax + IE = :(
Old 06-18-2008, 04:57 PM Ajax + FF = :), Ajax + IE = :(
HitSnapper.com's Avatar
Extreme Talker

Posts: 154
Location: England, UK
Trades: 0
Hi Guys,

I have a script which is using an ajax request to populate dropdown boxes (html <select> tags) depending on the first choice made by the user.

This is working PERFECTLY with firefox but IE is having none of it unfortunatly

The code i'm using is shown below

Ajax Request
Code:
var xmlHttp

function showModels(man)
{ 
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="getmodels.php"
url=url+"?m=" + man
xmlHttp.onreadystatechange=stateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById("models").innerHTML=xmlHttp.responseText
 }
 else{
	 document.getElementById("models").innerHTML="<option>Loading...</option>";
 }
}

function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
PHP
PHP Code:
include('includes/functions.php');

$manufacturer $_GET['m'];

if(!empty(
$manufacturer)){
    echo 
"<option value=\"\">Select Model</option>";
}

$result conn("SELECT DISTINCT `model` FROM `vehicles` WHERE `manufacturer`='".$manufacturer."'");
while(
$row mysql_fetch_array($result)){
    echo 
"<option value=\"".$row['model']."\">".$row['model']."</option>\n";

HTML
HTML Code:
<select id="make" name="make" onchange="showModels(this.value);">
<option value="">Select Make</option>
<option value="Audi">Audi</option>
</select>

<select id="models" name="model"></select>
Any help would be much appreciated

Thanks in advance

Craig

Last edited by HitSnapper.com; 06-18-2008 at 07:15 PM.. Reason: Change to AJAX request
HitSnapper.com is offline
Reply With Quote
View Public Profile Visit HitSnapper.com's homepage!
 
 
Register now for full access!
Old 06-18-2008, 05:52 PM Re: Ajax + FF = :), Ajax + IE = :(
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
I would suspect that the problem is related to using a variable name that is scoped both globally and locally

All things being equal it should not be a problem, but this is IE we are talking about.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-18-2008, 05:59 PM Re: Ajax + FF = :), Ajax + IE = :(
HitSnapper.com's Avatar
Extreme Talker

Posts: 154
Location: England, UK
Trades: 0
Thanks for the reply. The only variable name passed to the php script is ?m=MANUFACTURER_NAME and there are no globals in the php script (that i'm aware of!)

An yeah, IE gives me major headaches on an hourly basis

Craig
HitSnapper.com is offline
Reply With Quote
View Public Profile Visit HitSnapper.com's homepage!
 
Old 06-18-2008, 06:09 PM Re: Ajax + FF = :), Ajax + IE = :(
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
not the PHP. The javascript variables

xmlHttp is declared globally and then locally in GetXmlHttpObject()
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-18-2008, 06:31 PM Re: Ajax + FF = :), Ajax + IE = :(
HitSnapper.com's Avatar
Extreme Talker

Posts: 154
Location: England, UK
Trades: 0
Thanks for the reply. I tried removing it from the GetXmlHttpObject() and trying that, then removing it from the top of the script (not at the same time) but still no luck. Any other ideas? I've exhausted all the things I can think of on this
HitSnapper.com is offline
Reply With Quote
View Public Profile Visit HitSnapper.com's homepage!
 
Old 06-18-2008, 07:14 PM Re: Ajax + FF = :), Ajax + IE = :(
HitSnapper.com's Avatar
Extreme Talker

Posts: 154
Location: England, UK
Trades: 0
I edited the ajax request (see first post) and it still wasn't working so I deleted everything from the php file and replaced it with

HTML Code:
<option>Working</option>
This filled the second select box correctly, but now I changed back to the php code in the first post it doesn't work again. I'd appreciate any input you might have.

Thanks in advance,

Craig

Last edited by HitSnapper.com; 06-18-2008 at 07:16 PM..
HitSnapper.com is offline
Reply With Quote
View Public Profile Visit HitSnapper.com's homepage!
 
Old 06-18-2008, 07:38 PM Re: Ajax + FF = :), Ajax + IE = :(
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
IE has always been flaky on inserting elements into forms.

so rifling through the MS Knowledge base gets ->
http://support.microsoft.com/default...b;en-us;276228
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 06-19-2008, 05:18 AM Re: Ajax + FF = :), Ajax + IE = :(
HitSnapper.com's Avatar
Extreme Talker

Posts: 154
Location: England, UK
Trades: 0
Thankyou very much Chris, I now have the values changing, although not as expected, but i'll work on it. Once again, thanks! (rep added)

Craig
HitSnapper.com is offline
Reply With Quote
View Public Profile Visit HitSnapper.com's homepage!
 
Reply     « Reply to Ajax + FF = :), Ajax + IE = :(
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.67541 seconds with 12 queries