hellouthere Posted June 30, 2008 Share Posted June 30, 2008 Im trying to use a basic ajax navigation but cant get my function to work atall! this is the function pulled from the file function makerequest(serverPage, objID) { var obj = document.getElementByID(objID); xmlhttp.open("GET", serverPage, true); xmlhttp.onreadystatechange = function() { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) { obj.innerHTML = xmlhttp.responseText; } } xmlhttp.send(null); } Is there anything obviously wrong with this... I call the function on body load aswell as with hyperlinks, neither work. Quote Link to comment Share on other sites More sharing options...
hellouthere Posted June 30, 2008 Author Share Posted June 30, 2008 this is my ajax.js file //variable for IE instance check var xmlhttp = false; //Check for IE try { //If javascript version > 5 xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { //Older ActiveX try { //For IE xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { //Non-IE browser xmlhttp = false; } } //Create javascipt instance for Non-IE browser if (!xmlhttp && typeof XMLHttpRequest != 'undefined') { xmlhttp = new XMLHttpRequest(); } Quote Link to comment Share on other sites More sharing options...
rhodesa Posted June 30, 2008 Share Posted June 30, 2008 the only problem i had is getElementByID should be getElementById is the page your are trying to load on your domain? ...save yourself the hassle and use a JS library like jQuery. you could replace all this code with the following if you use jQuery: $('#'+objID).load(serverPage); Quote Link to comment Share on other sites More sharing options...
hellouthere Posted June 30, 2008 Author Share Posted June 30, 2008 thanks, ill look into jQuery Quote Link to comment Share on other sites More sharing options...
rhodesa Posted June 30, 2008 Share Posted June 30, 2008 but fyi...after changing getElementByID to getElementById, it worked fine for me in IE and FF Quote Link to comment Share on other sites More sharing options...
hellouthere Posted June 30, 2008 Author Share Posted June 30, 2008 yup, its working at the moment for me in both, ill stick with it as it is at the moment and look into jQuery soon 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.