Mattyspatty Posted November 5, 2006 Share Posted November 5, 2006 Hey i hope i can get some help on this one its really bugging me,i have a page that has links on and when you click the links a different page is included in the body of the page, all my links are fine except 1! it only stops working in IE, in FF its fine. All other links i have tried work perfectly fine in both IE and FF buts its just this 1 link that messes up IE![code]<td height="1" align="center"><a onClick="include('home')" href="#">Home</a></td><td height="1" align="center"><a onClick="include('military')" href="#">Military</a></td><td height="1" align="center"><a onClick="include('construction')" href="#">Construction</a></td><td height="1" align="center"><a onClick="include('inbox')" href="#">Messages</a></td> <!--Its this link that errors--><td height="1" align="center"><a onClick="logout()" href="#">Logout</a></td>[/code]i dont have a clue whats up with it, i guess its just IE is being a (*&$^ about it[code]function createRequestObject(){ var request_o; var browser = navigator.appName; if(browser == "Microsoft Internet Explorer"){ request_o = new ActiveXObject("Microsoft.XMLHTTP"); }else{ request_o = new XMLHttpRequest(); } return request_o;}var page = createRequestObject(); var stat = createRequestObject(); function include(myPage){ statsbar_update(); //alert(myPage); myForm = code_body; page.open('get', 'includes.php?page=' + myPage); page.onreadystatechange = handleInclude; page.send(null);}function handleInclude(){ switch(page.readyState) { case 4: var response = page.responseText; document.getElementById('include_area').innerHTML = response; break; default: document.getElementById('include_area').innerHTML = "Querying, Please Wait..."; page.onreadystatechange = handleInclude; }}function statsbar_update() { stat.open('get', 'statsbar.php'); stat.onreadystatechange = handleStatsbar; stat.send(null);}function handleStatsbar() { switch(stat.readyState) { case 4: var response = stat.responseText; document.getElementById('statsbar_area').innerHTML = response; break; default: document.getElementById('statsbar_area').innerHTML = "Querying, Please Wait..."; stat.onreadystatechange = handleStatsbar; }}[/code](optimisation comments appreciated;))thanks in advance, Matty Quote Link to comment https://forums.phpfreaks.com/topic/26220-ajax-erroring-in-ie-when-i-run-a-function-works-fine-in-ff/ Share on other sites More sharing options...
tomfmason Posted November 5, 2006 Share Posted November 5, 2006 What error are you getting in IE? Quote Link to comment https://forums.phpfreaks.com/topic/26220-ajax-erroring-in-ie-when-i-run-a-function-works-fine-in-ff/#findComment-119902 Share on other sites More sharing options...
Mattyspatty Posted November 5, 2006 Author Share Posted November 5, 2006 hehe, forgot about that... shoot me now!it just says "unknown runtime error" line 27, char 4, index2.php. the links and ajax inclusion are on index2.php Quote Link to comment https://forums.phpfreaks.com/topic/26220-ajax-erroring-in-ie-when-i-run-a-function-works-fine-in-ff/#findComment-119904 Share on other sites More sharing options...
tomfmason Posted November 5, 2006 Share Posted November 5, 2006 I know when I get that error it usaly means that there is an issue with the XMLHTTP instance Try this createRequestObject function (by ober)[code]function createRequestObject() { if (window.XMLHttpRequest) { // Mozilla, Safari, Opera... var xmlhttp = new XMLHttpRequest(); if (xmlhttp.overrideMimeType) xmlhttp.overrideMimeType('text/xml'); } else if (window.ActiveXObject) { // IE try { var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!xmlhttp) { alert('Giving up :( Cannot create an XMLHTTP instance'); return false; } return xmlhttp;}[/code]Also, have you tried looking in FF's javascript consule?Tom Quote Link to comment https://forums.phpfreaks.com/topic/26220-ajax-erroring-in-ie-when-i-run-a-function-works-fine-in-ff/#findComment-119912 Share on other sites More sharing options...
Mattyspatty Posted November 5, 2006 Author Share Posted November 5, 2006 hmm that didnt seem to work :(i had a look at the FF JSconsole and i got an error about document.getElementById(). i refreshed the js file and now FF shows no error. i did notice this however:line 26: document.getElementById('include_area').innerHTML = response;line 27: break;maybe its "document.getElementById('include_area')" erroring? i have used <div id="include_area"></div> but i dont see whats wrong with that! Quote Link to comment https://forums.phpfreaks.com/topic/26220-ajax-erroring-in-ie-when-i-run-a-function-works-fine-in-ff/#findComment-119916 Share on other sites More sharing options...
alpine Posted November 5, 2006 Share Posted November 5, 2006 Do you have a live link ? Quote Link to comment https://forums.phpfreaks.com/topic/26220-ajax-erroring-in-ie-when-i-run-a-function-works-fine-in-ff/#findComment-119924 Share on other sites More sharing options...
Mattyspatty Posted November 6, 2006 Author Share Posted November 6, 2006 no sorry, i am using my local computer to create this page and i dont want to give access to random people!i cant understand this problem, its only 1 link thats not working it makes no sense to me whatsoever :( thanks, matty Quote Link to comment https://forums.phpfreaks.com/topic/26220-ajax-erroring-in-ie-when-i-run-a-function-works-fine-in-ff/#findComment-120350 Share on other sites More sharing options...
ober Posted November 6, 2006 Share Posted November 6, 2006 eh... I've run into that error before. It's an absolute whore to troubleshoot. IE sucks for this kinda stuff.The only thing I can suggest is to throw more alerts in there to try and pop the error out into the open.I've also had trouble in the past when 2 events try to use an object at the same time. You might try creating more than one object instance and using a different object for each link. Quote Link to comment https://forums.phpfreaks.com/topic/26220-ajax-erroring-in-ie-when-i-run-a-function-works-fine-in-ff/#findComment-120351 Share on other sites More sharing options...
Mattyspatty Posted November 6, 2006 Author Share Posted November 6, 2006 [quote author=ober link=topic=113898.msg463651#msg463651 date=1162826953]eh... I've run into that error before. It's an absolute whore to troubleshoot. IE sucks [s]for this kinda stuff.[/s][/quote]ye its really annoying.. and, im not amazing at javascript but ill have a good go at alerting everything to find the problem, the new object instance idea sounds hopeful too.thanks for your input, ill let you know if i have any more problems.Matty Quote Link to comment https://forums.phpfreaks.com/topic/26220-ajax-erroring-in-ie-when-i-run-a-function-works-fine-in-ff/#findComment-120352 Share on other sites More sharing options...
Mattyspatty Posted November 6, 2006 Author Share Posted November 6, 2006 ok i have found out what was causing the error[code]document.getElementById('include_area').innerHTML = response;[/code] will not run, it gets upto that line and errors when i click my problem link. [code]document.getElementById('include_area').innerHTML = "test";[/code] the above code worked fine!!, i can only assume it is the page i am including causing a problem, i took a wild last hope attempt at trying anything just to see if it works an i almost had a heart attack! i have a FORM on the page i was including, i deleted that and all was fine and dandy!!! ill be able to sleep tonight ;)its just one of those things i guess...thanks for your input guys much appreciated :)Matty Quote Link to comment https://forums.phpfreaks.com/topic/26220-ajax-erroring-in-ie-when-i-run-a-function-works-fine-in-ff/#findComment-120493 Share on other sites More sharing options...
ober Posted November 6, 2006 Share Posted November 6, 2006 oh yeah... I should have remembered that's what caused my former headaches. For some reason IE doesn't like form tags in the response. Quote Link to comment https://forums.phpfreaks.com/topic/26220-ajax-erroring-in-ie-when-i-run-a-function-works-fine-in-ff/#findComment-120498 Share on other sites More sharing options...
r-it Posted June 4, 2007 Share Posted June 4, 2007 what else can you use if you ommit the form tag then? Quote Link to comment https://forums.phpfreaks.com/topic/26220-ajax-erroring-in-ie-when-i-run-a-function-works-fine-in-ff/#findComment-267622 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.