giba Posted May 19, 2009 Share Posted May 19, 2009 Hi there! I am issuing a problem with IE that I can't solve it, because in all other browsers it work perfectly. I did a simple script that gets the HTML from an element by its class name, send it via ajax and gets the result from a .php file which contains a Google script for translation, the problem however is that only Internet explorer returns nothing. The question is: How can I send the HTML of an element and get it back on IE based on a loop that cicles AJAX requests? Follows de script I used: The code for getting the element by its class name: document.getElementsByClassName = function(class_name) { var docList = this.all || this.getElementsByTagName('*'); var matchArray = new Array(); var re = new RegExp("(?:^|\\s)"+class_name+"(?:\\s|$)"); for (var i = 0; i < docList.length; i++) { if (re.test(docList[i].className) ) { matchArray[matchArray.length] = docList[i]; } } return matchArray; } The code for looping through the elements with the class "translate": var trans = document.getElementsByClassName('translate'); for ( var i = 0; i < trans.length; i++) { t = trans[i]; translate(t,'translate.php?string='+escape(t.innerHTML.replace(/[\r\n]+/g, ""))+'&l=<?=$_GET['l'];?>&c='+Math.random()) } And the code for AJAX: function translate(target, url) { var xmlhttp; if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else if (window.ActiveXObject) { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } else { alert("Your browser does not support XMLHTTP!"); } xmlhttp.onreadystatechange = function(){ if (xmlhttp.readyState == 4) { target.innerHTML = xmlhttp.responseText; //alert(xmlhttp.responseText); } } xmlhttp.open("GET", url, true); xmlhttp.send(null); } Quote Link to comment Share on other sites More sharing options...
giba Posted May 20, 2009 Author Share Posted May 20, 2009 After dealing a lot with GET requests I found that IE limits the value of 500 charactes per value of a parameter in the Query String, so I dealt with this fragmenting my code in more peaces. Not the best choise, but works!!!! 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.