•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,610 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,608 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting
Views: 997 | Replies: 3 | Solved
![]() |
•
•
Join Date: Jan 2006
Posts: 13
Reputation:
Rep Power: 3
Solved Threads: 1
Hello all,
I'm using AJAX to populate a div tag in my HTML when a drop down list item is selected. It works perfectly in Safari, Firefox, Opera, but fails in IE. The responseText just comes back blank from the php script.
Here's the Javascript it has to deal with:
And here's the php script I'm using to fetch some data from the MySQL server:
Thanks in advance for any help!
I'm using AJAX to populate a div tag in my HTML when a drop down list item is selected. It works perfectly in Safari, Firefox, Opera, but fails in IE. The responseText just comes back blank from the php script.
Here's the Javascript it has to deal with:
function GetXmlHttpObject()
{
xmlHttp = null;
try
{
// Firefox, Opera, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP"); // 6.0+
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP"); // 5.5+
}
}
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
var response = xmlHttp.responseText;
document.getElementById("contentBox").innerHTML=response;
}
}And here's the php script I'm using to fetch some data from the MySQL server:
<?php
$id = $_GET["id"];
include('connect.php');
$theQuery = mysql_query("select post from archive where title='" . $id . "'");
$row = mysql_fetch_assoc($theQuery);
echo $row['post'];
?>Thanks in advance for any help!
•
•
Join Date: Jan 2006
Posts: 13
Reputation:
Rep Power: 3
Solved Threads: 1
Thanks for such a general answer.
I really have no idea what "script" you're referring to. Do you mean my php script including 'connect.php'? Because that's only information it needs to connect to the server and won't change at all.
Maybe I forgot to mention, or maybe you just forgot to read the part where I said it works in Firefox, Safari, and Opera. I think it's a problem with the way IE is interpreting the document type. Maybe it's trying to parse it before it gets to the page. Again this is only happening in IE so there's nothing wrong with my code, I just need to add something to make it work with IE.
I really have no idea what "script" you're referring to. Do you mean my php script including 'connect.php'? Because that's only information it needs to connect to the server and won't change at all.
Maybe I forgot to mention, or maybe you just forgot to read the part where I said it works in Firefox, Safari, and Opera. I think it's a problem with the way IE is interpreting the document type. Maybe it's trying to parse it before it gets to the page. Again this is only happening in IE so there's nothing wrong with my code, I just need to add something to make it work with IE.
•
•
Join Date: Jan 2006
Posts: 13
Reputation:
Rep Power: 3
Solved Threads: 1
If anybody else runs across this problem, I've come across the solution (thanks to BetaWar on dreamincode.net).
The following is the code I have now. IE wasn't recognizing what this.value was because I didn't have the value attribute in the option tag. I was assuming that "this.value" was being fetched from the text inside the option tags. I assumed wrong I guess.
The following is the code I have now. IE wasn't recognizing what this.value was because I didn't have the value attribute in the option tag. I was assuming that "this.value" was being fetched from the text inside the option tags. I assumed wrong I guess.
syntax Syntax (Toggle Plain Text)
<select id="post" onchange="changePost(this.value);"> <?php include('php/connect.php'); if(mysql_num_rows($result) > 0) { while($row = mysql_fetch_assoc($result)) { $id = $row['pk']; $title = $row['title']; echo "<option id=\"".$id."\" value=\"".$title."\">".$title."</option>\n"; } } mysql_close($con); ?> </select>
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
Similar Threads
- Please check my code below (Java)
- file upload (JavaScript / DHTML / AJAX)
- Forms with AJAX (JavaScript / DHTML / AJAX)
- Unresponsive script (DaniWeb Community Feedback)
- Parse XML from ASP!!! (ASP)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: resize not working
- Next Thread: pls help me



Linear Mode