# AJAX help

**URL:** <https://forum.kirupa.com/t/ajax-help/220655>\
**Category:** web dev\
**Created:** [March 28, 2007, 2:36am UTC](https://forum.kirupa.com/t/ajax-help/220655 "2007-03-28T02:36:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![FlashHed](https://avatars.discourse-cdn.com/v4/letter/f/e480ec/32.png) [@FlashHed](https://forum.kirupa.com/u/FlashHed)\
**Post date:** [March 28, 2007, 2:36am UTC](https://forum.kirupa.com/t/ajax-help/220655/1 "2007-03-28T02:36:22Z")

</div>

I’m new to AJAX, and would like to include it on my website. I have this code I’m working with. Basically what I want is to use one ‘page\_handler’ and one ‘add\_url’ function to handle all of my links. Any help would be appreciated. Here’s the code.

\<html\>  
\<head\>  
\<title\>Untitled Document\</title\>  
\<script type=“text/javascript”\>  
function make\_request(span\_id,url){  
var receiveReq = getXmlHttpRequestObject();  
var url = “”;  
var content = “”;  
function getXmlHttpRequestObject() {  
if (window.XMLHttpRequest) {  
return new XMLHttpRequest(); //Not IE  
} else if(window.ActiveXObject) {  
return new ActiveXObject(“Microsoft.XMLHTTP”); //IE  
} else {  
alert(“This site uses AJAX, please upgrade to Mozilla Firefox.”);  
}  
}  
function page\_handler(span\_id) {  
if (receiveReq.readyState == 4) {  
document.getElementById([span\_id]).innerHTML = receiveReq.responseText;  
}  
}  
function add\_link(url) {  
if (receiveReq.readyState == 4 || receiveReq.readyState == 0) {  
receiveReq.open(“GET”, url, true);  
receiveReq.onreadystatechange = page\_handler;  
receiveReq.send(null);  
}  
}  
}  
\</script\>  
\</head\>

\<body\>  
\<a href=“javascript:make\_request(“content”,“home.html”);”\>Home\</a\>\<br\>  
\<a href=“javascript:make\_request(“content”,“portfolio.html”);”\>Portfolio\</a\>\<br\>  
\<a href=“javascript:make\_request(“content”,“contact.html”);”\>Contact\</a\>\<br\>  
\<span id=“content”\>Alternate Text goes Here\</span\>  
\</body\>  
\</html\>
