This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
The moose likes HTML, CSS and JavaScript and the fly likes Ajax not working Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Ajax not working " Watch "Ajax not working " New topic

Ajax not working

Mahtab Alam
Ranch Hand

Joined: Mar 28, 2012
Posts: 249

<title> This is Using Ajax</title>

<script language="javascript">

var XMLHttpRequestObject=false;

XMLHttpRequestObject=new XMLHttpRequest();
else if(window.ActiveXObject)
XMLHttpRequestObject=new ActiveXObject("Microsoft.XMLHTTP");

function getdata(datasource,divID)
var tag=document.getElementById(divID);"GET",datasource);

if(XMLHttpRequestObject.readyState==4 && XMLHttpRequestObject.status==200)


<input type="button" value="Click to see message"

<div id="targetDiv">
<p> Your Message Will Appear Here</p>

File mata.txt have just a line
But when i click the button it does not retrieve data from the file

Oracle Java Programmer , Oracle SQL Expert , Oracle Java Web Component Developer
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 61103

First, please repost the code using proper indentation and UseCodeTags.

Second, use the browser's debugger to step through the code and see what's going wrong. The network panel will tell you whether the request even fires off or not.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
It is sorta covered in the JavaRanch Style Guide.
subject: Ajax not working