Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Ajax
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Ajax the combination of XHTML, CSS, DOM, XML, XSLT, XMLHttpRequest, and JavaScript
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Ajax section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 20th, 2011, 06:32 PM
Friend of Wrox
Points: 1,075, Level: 12
Points: 1,075, Level: 12 Points: 1,075, Level: 12 Points: 1,075, Level: 12
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2005
Location: , , United Kingdom.
Posts: 244
Thanks: 3
Thanked 4 Times in 4 Posts
Default Button Updating Div

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
__________________
Apocolypse2005, I'm a programmer - of sorts.
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Page Container <div> and another ,div. not behaving as expected SouthendSupporter ASP.NET 3.5 Basics 8 December 15th, 2009 09:05 AM
div within a div and inherting the height brettdavis4 CSS Cascading Style Sheets 1 January 23rd, 2007 08:59 AM
Make a image button as default submit button toshi ASP.NET 1.0 and 1.1 Basics 1 June 1st, 2006 05:25 AM
how to use 'Enter' button to trigger a button, thx raybristol ASP.NET 1.0 and 1.1 Basics 1 December 16th, 2005 05:56 AM
Button acts depending on radio button values janise Access 4 March 9th, 2004 11:53 PM



All times are GMT -4. The time now is 01:24 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.