File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How to run ajax program" Watch "How to run ajax program" New topic
Author

How to run ajax program

Suganya Rajarethinam
Greenhorn

Joined: Sep 10, 2008
Posts: 11
Hi,
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.

<html>
<head>
<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
//http_request.overrideMimeType('text/xml');
http_request.overrideMimeType('text/html');
}
} 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;
http_request.open('GET', url + parameters, true);
http_request.send(null);
}

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.');
}
}
}
</script>
</head>
<body>
<a href="javascript: makeRequest('http://www.expertsforge.com/fullstory.asp','content','?topicid=8');">Request Page</a>
<div id="content"></div>
</body>
</html>
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

read this to understand the concept.


Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
Eric Pascarello
author
Rancher

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

Eric
Suganya Rajarethinam
Greenhorn

Joined: Sep 10, 2008
Posts: 11
Hi,

Thanks for your reply....



Regards,
Suganya R.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to run ajax program
 
Similar Threads
Ajax Hello World example using Servlet
'Undefined' Error with PHP and AJAX
Simple Ajax example doesn't work
New to Ajax
Java Dynamic Servlet