File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
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: 388

<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, Oracle Web Service Developer
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63866

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] [About Bear] [Books by Bear]
I agree. Here's the link:
subject: Ajax not working
It's not a secret anymore!