domk Posted July 8, 2008 Share Posted July 8, 2008 hi there im now sitting on the problem for more then 8h and just cant get on with it... ill appreciate any help here problem: ajax javascript/php framework the following code works just fine in any browser but in ie6 where it does not give me any error messages and works only sometimes and other times not at all(what it does then is nothing...) html code here <script type="text/javascript"> <!-- function setTitle(title,msgT) { //... alert(msgT); } // Get the HTTP Object function getHTTPObject() { try { return new XMLHttpRequest(); //return default ajax request } catch (trymicrosoft) { //ie try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (othermicrosoft) { //ie try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch (failed) { alert("Your browser does not support AJAX."); return null; } } } } // Change the value of the outputText field function setOutput() { if(httpObject.readyState == 4){ var responseText = httpObject.responseText; eval(httpObject.responseText); //execute ajax framework } } // Implement business logic function doWork(t) { httpObject = getHTTPObject(); if (httpObject != null) { httpObject.open("GET", "resource.php?idurl="+t, true); httpObject.send(null); httpObject.onreadystatechange = setOutput; } } var httpObject = null; //straighten it all out //--> </script> <br><br><br><br> <a href="javascript:doWork('photos/pic10');">test</a> and the php code in resource.php <?php //some connection code missing here... $result = mysql_query("select url,title,msg from ".$table." where url = '".trim($_GET["idurl"])."' Limit 1"); $res = mysql_fetch_array($result); $msgTT=str_replace(" "," ",trim(nl2br(addslashes($res[msg])))); $msgTT=str_replace("\n","",$msgTT); $msgTT=str_replace("\r","",$msgTT); echo ' titleT="'.trim(addslashes($res[title])).'"; msgTT="'.$msgTT.'"; setTitle(titleT,msgTT);'; ?> id even try to replace eval() with a simple alert function which seem to have to very same effect... if anyone can come up with anything here ill be grateful! cheers Link to comment https://forums.phpfreaks.com/topic/113710-simple-ajax-framework-in-ie6-unstable/ Share on other sites More sharing options...
domk Posted July 8, 2008 Author Share Posted July 8, 2008 found the problem which laid in the caching instance of ie6 function doWork(t) { httpObject = getHTTPObject(); if (httpObject != null) { var randomID = Math.random() * Date.parse(new Date()); //random string to prevent caching httpObject.open("GET", "resource.php?idurl="+t+"&rand="+randomID, true); httpObject.send(null); httpObject.onreadystatechange = setOutput; } thats what it looks like now Link to comment https://forums.phpfreaks.com/topic/113710-simple-ajax-framework-in-ie6-unstable/#findComment-584330 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.