| | |
AJAX Not working with IE6-IE8 Browsers
Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Mar 2008
Posts: 36
Reputation:
Solved Threads: 0
Have been trying to figure this one out for some time, but still can not get this AJAX script to work with Internet Explorer. It works with all other browsers. Thanks in Advance!
FORM CODE
aj.php CODE
aj.js AJAX POST CODE
FORM CODE
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<script language="JavaScript" type="text/javascript" src="aj.js"> </script> <input type="text" value="#CCC" id="paints" size="7"> <input type="button" value="submit" id="gColor" onclick= "handleIT();colorIT()"> <input type="text" id="textBack"> <div class="c1" id="divBack">Dynamically Paint Here.</div>
aj.php CODE
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
<?php $paint = trim($_POST['paints']); echo trim($paint); ?>
aj.js AJAX POST CODE
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
function getXmlHttpRequestObject() { if (window.XMLHttpRequest) { return new XMLHttpRequest();} else if(window.ActiveXObject) { return new ActiveXObject("Microsoft.XMLHTTP");} else {}} var search7 = getXmlHttpRequestObject(); function handleIT() { if (search7.readyState == 4 || search7.readyState == 0) { var paints = escape(document.getElementById('paints').value); var parameters="paints="+paints; search7.open("POST", 'aj.php', true); search7.onreadystatechange = colorIT; search7.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); search7.send(parameters); }} function colorIT() { if (search7.readyState == 4) { var paints = escape(document.getElementById('paints').value); document.getElementById("textBack").value=search7.responseText; document.getElementById("divBack").style.backgroundColor=search7.responseText; }}
Try the following format:
aj.js
Let me know, if you're still getting the same issue...
aj.js
javascript Syntax (Toggle Plain Text)
var paints, parameters, search7, colorIT; colorIT = function() { if ( search7.readyState === 4 ) { document.getElementById("textBack").value = search7.responseText; document.getElementById("divBack").style.backgroundColor = search7.responseText; } }; function getXmlHttpRequestObject() { search7 = null; paints = escape( document.getElementById("prints").value ); parameters = "paints=" + paints; if ( window.XMLHttpRequest ) { search7 = new XMLHttpRequest(); } else if ( window.ActiveXObject ) { try { search7 = new ActiveXObject("Microsoft.XMLHTTP"); } catch( e ) { search7 = new ActiveXObject("Msxml2.XMLHTTP"); } } if ( search7 !== null ) { search7 = ( search7.overrideMimeType ) ? search7.overrideMimeType("text/xml") : search7; search7 = ( search7.setRequestHeader ) ? search7.setRequestHeader("Content-Type", "application/x-www-form-urlencoded") : search7; search7.onreadystatechange = colorIT; search7.open("POST", "aj.ph", true); search7.send( parameters ); } else { alert("\nYour browser does not support AJAX Request!"); } }
Let me know, if you're still getting the same issue...
Last edited by essential; Apr 30th, 2009 at 11:00 pm.
•
•
Join Date: Mar 2008
Posts: 36
Reputation:
Solved Threads: 0
The code I originally posted works in function but according to the Internet Explorer Team they found.
===== IE Team Response =====
From an analysis of the IE folks, it seems that the problem is generated by some whitespace in your string
00380023 00380038 0000000a
This fails:
document.getElementById("divBack").style.backgroundColor=search7.responseText;
Error is Invalid property value.
===== IE Team Response =====
From an analysis of the IE folks, it seems that the problem is generated by some whitespace in your string
00380023 00380038 0000000a
This fails:
document.getElementById("divBack").style.backgroundColor=search7.responseText;
Error is Invalid property value.
•
•
Join Date: Mar 2008
Posts: 36
Reputation:
Solved Threads: 0
The code does not work, because of some weird whitespace being passed that is what microsoft said. YOu can see the code in function at the below url. It works with all browsers except Internet Explorer.
http://89.233.173.91/bug/
The sample is running the code originally posted on this thread.
http://89.233.173.91/bug/
The sample is running the code originally posted on this thread.
•
•
Join Date: Mar 2008
Posts: 36
Reputation:
Solved Threads: 0
you can see the original code behavior at the following http://89.233.173.91/bug/ It works with any browser except IE. Have tried not escaping and get the same error....
Would you prefer using a different method?
How about a function that will filter a user input, then set it as direct style of the object?
Example:
Im sure there's a way to defeat the bug...
Just try to play some experiment in your function's.
How about a function that will filter a user input, then set it as direct style of the object?
Example:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
if ( document.all ) { div = document.all.divBack; div.setAttribute("style", "background-color : " + search7.responseText + ";"); }
Just try to play some experiment in your function's.
![]() |
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: can't call this function...
- Next Thread: Swapping data from textbox1 to textbox2 & textbox2 to textbox1 in 1 onclick event
Views: 2718 | Replies: 7
| Thread Tools | Search this Thread |
Tag cloud for JavaScript / DHTML / AJAX
acid2 ajax ajaxcode ajaxexample ajaxhelp animate array automatically autoplay beta boarder box button captcha card cart codes column css date debugger decimal design developer dom download element embed enter error events firefox flash focus form frameworks getselection google gwt hint html htmlform ie7 iframe image() index java javascript javascripthelp2020 javascripts jawascriptruntimeerror jquery jsp listbox maps marquee masterpage menu microsoft mimic mp4 offline onmouseover parameters paypal php player position post problem programming prototype rating redirect regex safari scale scriptlets search select size sources sql starrating textarea toggle tweet twitter validation variables w3c web webkit webservice website window windowofwords windowsxp xml xspf





