Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Ajax
Password Reminder
| FAQ | Members List | 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
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old July 21st, 2015, 09:28 PM
Authorized User
Points: 132, Level: 2
Points: 132, Level: 2 Points: 132, Level: 2 Points: 132, Level: 2
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Nov 2012
Posts: 25
Thanks: 3
Thanked 0 Times in 0 Posts
Question Simple Ajax code will not work.

I'm doing this very simple Ajax code but, for some reason I can't get it to work. Could someone show me what I am doing wrong?

The code is below:
<!DOCTYPE html>
<script language = "javascript">

var XMLHttpRequestObject = false;
		XMLHttpRequestObject - new XMLHttpRequest();
	else if(window.ActiveXObject)
		XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHttp");
function getData(dataSource, divID)

	var obj = document.getElementById(divID)
		XMLHttpRequestObject.open("GET", dataSource);
		XMLHttpRequestObject.onreadystatechange = function()
			if(XMLHttpRequestObject.readyState == 4 && XMLHttpRequestObject.status == 200)
				obj.innerHTML = XMLHttpRequestObject.responseText;
				obj.innerHTML = <strong>Waitning for response...</strong>
<div id="text">
<p>Response will appear here.</p>
	<input type = "button" value = "Submit" onclick="getData('HelloWorld.php','divID')">

Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
Ajax authentication service class doesn't work with ToolKitScriptManagerl ravi shiggavi BOOK: ASP.NET AJAX Programmer's Reference : with ASP.NET 2.0 or ASP.NET 3.5 ISBN: 978-0-470-10998-4 0 May 17th, 2010 01:36 AM
ch11 "Using XML and Ajax" example doesn't work nick_rasband@byu.net BOOK: Beginning Ruby on Rails 2 March 27th, 2007 06:13 PM
code clinic - Why wont example asp code work? jardbf Classic ASP Basics 3 April 27th, 2006 06:22 PM
Chapter 15 simple-mailer.php doesn't work Corey Wirun BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 June 18th, 2003 03:13 PM

All times are GMT -4. The time now is 06:34 AM.

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