Zergman Posted April 12, 2011 Share Posted April 12, 2011 Using ajax to perform a simple query using a dropdown that retrieves a template from the mysql table and loads that template into a textarea. When it loads into the textarea, the formatting is kept in FF perfectly. In all versions of IE, it loses the formatting. Example Firefox 1 2 3 Internet Explorer 1 2 3 The textarea <textarea name="coach_details" id="txtHint" class="textareastyle" style="width:99%;" rows="20" ><?php echo set_value('coach_details');?></textarea> Javascript function showUser(str) { if (str=="") { document.getElementById('txtHint').innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById('txtHint').innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","get_template.php?q="+str,true); xmlhttp.send(); } get_template.php <?php $q=$_GET["q"]; $con = mysql_connect('localhost', 'username', 'password'); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db", $con); $sql=" SELECT template FROM coaching WHERE menu_id = '$q' "; $result = mysql_query($sql); $row = mysql_fetch_array($result); $template = $row['template']; echo $template; mysql_close($con); ?> I'm so stuck. Sadly though our company still uses IE alot so has to work for both. Suggestions? Quote Link to comment Share on other sites More sharing options...
Zergman Posted April 12, 2011 Author Share Posted April 12, 2011 Only possible causes I found was that someone mentioned that IE has issues with large text using GET and suggested using POST but i couldn't figure out how to modify my code to use POST. Quote Link to comment Share on other sites More sharing options...
dcro2 Posted April 12, 2011 Share Posted April 12, 2011 Could you give us an actual example of what will be in the textarea? Could have to do with special characters that html needs passed through html_entities. Quote Link to comment Share on other sites More sharing options...
Zergman Posted April 12, 2011 Author Share Posted April 12, 2011 Here's is one of the templates Firefox TT#: Please be sure to check for open/pending tickets before beginning a new Trouble Ticket. For more information please refer to xxxx regarding Second or Subsequent Call - How to add Activities to an Existing TT: http://long_url TT#: Please be sure to check for open/pending tickets before beginning a new Trouble Ticket. For more information please refer to the xxxx regarding Second or Subsequent Call - How to add Activities to an Existing TT: http://long_url IE TT#: Please be sure to check for open/pending tickets before beginning a new Trouble Ticket. For more information please refer to xxxx regarding Second or Subsequent Call - How to add Activities to an Existing TT: http://long_url Should also mention i've tried setting the mysql field type to blob to text, neither seemed to make a difference. Quote Link to comment Share on other sites More sharing options...
Zergman Posted April 13, 2011 Author Share Posted April 13, 2011 I tested this by adding a new entry right through phpmyadmin into the database 1 2 3 a b c So there's no special characters or anything. Firefox 1 2 3 a b c IE 1 2 3 a b c Could this just be IE being stupid? Quote Link to comment Share on other sites More sharing options...
dcro2 Posted April 13, 2011 Share Posted April 13, 2011 Just had a thought.. it may be because the html code around or before it is invalid. Have you run it through the W3C validator? Quote Link to comment Share on other sites More sharing options...
Zergman Posted April 13, 2011 Author Share Posted April 13, 2011 Just had a thought.. it may be because the html code around or before it is invalid. Have you run it through the W3C validator? I have and it checked fine. I built a small test app that does the same thing and it worked fine. Couple things that are different in the above is that im using fancybox to show the div in a popup. Also using Codeigniter. hmmmm Quote Link to comment Share on other sites More sharing options...
Zergman Posted April 13, 2011 Author Share Posted April 13, 2011 Was wondering if it was due to it being contained in div tags, nope. Made it it's own window, same thing. Quote Link to comment Share on other sites More sharing options...
Zergman Posted April 14, 2011 Author Share Posted April 14, 2011 Did more looking and think this is how it should look, but yet, not working. function showUser(str) { var xmlhttp; if (str=="") { document.getElementById('txtHint').innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById('txtHint').innerHTML=xmlhttp.responseText; } } xmlhttp.open("POST","http://mysite.com/site/assets/includes/get_template.php",true); xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded"); xmlhttp.send(str); } Changed the get_template to $q = $_POST["str"]; Any ideas? Quote Link to comment Share on other sites More sharing options...
Zergman Posted April 14, 2011 Author Share Posted April 14, 2011 well now I really give up. Got it working using POST and no change. WTF lmao Quote Link to comment Share on other sites More sharing options...
Muddy_Funster Posted April 14, 2011 Share Posted April 14, 2011 Looks like it's an issue with the way the line break is being stored/retrieved from the database. I am willing to bet the database is either storing or feeding the line breakes in *nix format, and IE, being IE, gets all upset because it's not windows format. Just a thought, but check on the line break code and see what it's using. 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.