Hi,
I have a button on my page, and I want it to dynamically update the content of this <div> which has the id='mrs'.
I have tried and failed on several occasions. Any idea how to do it would be great. Please include code in the answer. I've tried various attempts of using the ajax html page requests and stuff.
Code:
function ajaxpage(div_id){
var page_request = false
if (window.XMLHttpRequest)
{ // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
}
else if (window.ActiveXObject)
{ // if IE
try
{
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e)
{
alert(e);
try
{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){
alert(e);
}
}
}
else
{
return false
}
page_request.onreadystatechange=function(){
addHtml(page_request, div_id);
}
}
function addHtml(page_request, div_id)
{
if (page_request.readyState == 4 && page_request.status==200)
var dr = document.getElementById(div_id).innerHTML;
dr.innerHTML = "<a onclick='removeThis();'>Added Element</a>";
}
That's my failed attempt. Oh and if anyone can suggest how to do that "removeThis();" function which removes that given hyperlink that would be great!!
Cheers