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 How to run ajax program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Make it so: Java DB Connections & Transactions this week in the JDBC forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to run ajax program" Watch "How to run ajax program" New topic

How to run ajax program

Suganya Rajarethinam

Joined: Sep 10, 2008
Posts: 11
I am new to the Ajax program. I have one simple Ajax program.But i didn't know how to run this program.What are the requirements are needed to run the Ajax program.Can any one help to me.. Here am sending that program.

<title>Request External Web Page containing parameters using Ajax</title>
<script language="javascript" type="text/javascript">
function makeRequest(url, containerid, parameters) {
http_request = false;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
http_request = new XMLHttpRequest();
if (http_request.overrideMimeType) {
// set type accordingly to anticipated content type
} else if (window.ActiveXObject) { // IE
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
if (!http_request) {
alert('Cannot create XMLHTTP instance');
return false;
http_request.onreadystatechange = alertContents;'GET', url + parameters, true);

function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
result = http_request.responseText;
document.getElementById('content').innerHTML = result;
} else {
alert('There was a problem with the request.');
<a href="javascript: makeRequest('','content','?topicid=8');">Request Page</a>
<div id="content"></div>
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

read this to understand the concept.

[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Eric Pascarello

Joined: Nov 08, 2001
Posts: 15385
You can not call another domain with Ajax. Is that your issue with running tat example?

Suganya Rajarethinam

Joined: Sep 10, 2008
Posts: 11

Thanks for your reply....

Suganya R.
I agree. Here's the link:
subject: How to run ajax program
It's not a secret anymore!