| | |
responseText is empty in IE
Thread Solved |
•
•
Join Date: Jan 2006
Posts: 14
Reputation:
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:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
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:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<?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: 14
Reputation:
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: 14
Reputation:
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.
JavaScript / DHTML / AJAX 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>
![]() |
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
Views: 4053 | Replies: 3
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
ajax ajaxhelp animate array asp attributes auto automatically blackjack box bug button captchaformproblem character codingproblem column content css design detect div dom dynamic eclipse editor element error explorer ext external file firefox flash focus form forms function game google hide html iframe image index internet internet-explorer internetexplorer java javascript javascripts jquery js library login maps masterpage match menu mimic modal mysql object offline onclick onerror onmouseover opacity parameters php player position post problem prototype rated referenceerror repaeat resize scroll search select selection show size source star strings synchronous table text variables video web web-development website window wysiwyg xml xspf \n






