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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.