ajaxextraordinaire Posted July 4, 2009 Share Posted July 4, 2009 Hi, Created my first AJAX script , and while it works fine in Firefox, it doesn't work at all in IE, not even a response. Put error messages in and it appears to fail on the part where it replaces the <tr> innerhtml right at the end. Curiously, it also fails the HTML earlier on , so some sort of problem with Getelementbyid? ==== <script type="text/javascript"> function refreshhandsets(type,point) { var point; var type; var oldhtml = document.getElementById("sl"); var minpoint = point-7; var newpointleft = Math.max(1,minpoint); var newpointright = Math.max(point,; alert(document.getElementById('sl').onclick) var newhtml = "refreshhandsets("+type+","+newpointleft+")"; var newhtmlright = "refreshhandsets("+type+","+newpointright+")"; alert ("about to set attributes"); document.getElementById("sl").setAttribute("onclick",newhtml); document.getElementById("sr").setAttribute("onclick",newhtmlright); alert ("now onto ifs"); if (type == 1) { document.getElementById("cont").setAttribute("class","selected"); document.getElementById("pg").setAttribute("class",""); } if (type == 2) { document.getElementById("pg").setAttribute("class","selected"); document.getElementById("cont").setAttribute("class",""); } alert ("about to get objects"); xmlhttp=GetXmlHttpObject(); if (xmlhttp==null) { alert ("Browser does not support HTTP Request"); return; } alert ("done http object thing"); var url="ajaxhandsets.php"; url=url+"?type="+escape(type); url=url+"&point="+escape(point); alert ("created url"); xmlhttp.onreadystatechange=stateChanged; xmlhttp.open("GET",url,true); xmlhttp.send(null); alert ("end of onclick func"); } function stateChanged() { if (xmlhttp.readyState==4) { alert ("recieving response"); var element = document.getElementById("phonephotos"); alert(element.innerHTML); element.innerHTML = xmlhttp.responseText; alert ("and finally! updated HTML"); } } function GetXmlHttpObject() { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari return new XMLHttpRequest(); } if (window.ActiveXObject) { try { page_request = new ActiveXObject("Msxml2.XMLHTTP") } catch (e){ try{ page_request = new ActiveXObject("Microsoft.XMLHTTP") } catch (e){} } } else return null } </script> ==== HTML Snippets : <li id="cont" class="selected" onclick="refreshhandsets(1,1)"><a href="#"><span>contract</span></a></li> <li id ="pg" onclick="refreshhandsets(2,1)"><a href="#"><span>pay as you go</span></a></li> <a id="sl" class="slide left" href="#" onclick="refreshhandsets(1,1)"><span>slide left</span></a> <tr id="phonephotos"> ** Lots of images in td's** </tr> <a class="slide right" href="#" id="sr" onclick ="refreshhandsets(1,"><span>slide right</span></a> Any help much appreciated! Quote Link to comment Share on other sites More sharing options...
ajaxextraordinaire Posted July 4, 2009 Author Share Posted July 4, 2009 Hi All, believe i managed to solve this. Seems IE wont let me change <tr> with Javascript, I made it replace the entire table, and it works. Thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.