Jump to content

[SOLVED] Non-function


hellouthere

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/112597-solved-non-function/
Share on other sites

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();
}

 

 

Link to comment
https://forums.phpfreaks.com/topic/112597-solved-non-function/#findComment-578277
Share on other sites

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);

Link to comment
https://forums.phpfreaks.com/topic/112597-solved-non-function/#findComment-578278
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.