# Help with ajax and replace funcion

**URL:** https://forum.kirupa.com/t/help-with-ajax-and-replace-funcion/243300
**Category:** Uncategorized
**Created:** [November 5, 2007, 3:54pm UTC](https://forum.kirupa.com/t/help-with-ajax-and-replace-funcion/243300 "2007-11-05T15:54:48Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![alapimba](https://avatars.discourse-cdn.com/v4/letter/a/ea666f/32.png) [@alapimba](https://forum.kirupa.com/u/alapimba)
#### Post date: [November 5, 2007, 3:54pm UTC](https://forum.kirupa.com/t/help-with-ajax-and-replace-funcion/243300/1 "2007-11-05T15:54:48Z")

</div>

Hello, can anyone help me with this function?

i’m doing a replace, the content appears inside the div “foo”.

now i want to have like 3 or 4 links with the funcione replace and each one replace his own content.

my code so far and working is:

```auto
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<script type="text/javascript">
var http = false;
if(navigator.appName == "Microsoft Internet Explorer") {
  http = new ActiveXObject("Microsoft.XMLHTTP");
} else {
  http = new XMLHttpRequest();
} 
function replace() {
  http.open("GET", "conteudo.php?id=1", true);
  http.onreadystatechange=function() {
    if(http.readyState == 4) {
      document.getElementById('foo').innerHTML = http.responseText;
    }
  }
  http.send(null);
}
</script> 
 
</head>
<body>
<div class="accordion_content">
    <h2><p><a href="javascript:replace()">link 1</a></p>
<div id="foo">
  here appear the content
</div></h2>
</body>

```
