/    Sign up×
Community /Pin to ProfileBookmark

how to run ajax on tomcat webserver??

guys …
i have use the ajax http request to do smart refresh…and it work fine when i am using the apache webserver….
however, when i wanna run it on the tomcat webserver, it seem to keep prompting error mssg..

the system keep prompting alert (this code always run) :
alert(‘There was a problem with the request.’);

here is my code:
<script language=”JavaScript”>
setTimeout(‘get()’,1000);

var http_request = false;

function makePOSTRequest(url, 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(‘POST’, url, true);
http_request.setRequestHeader(“Content-type”, “application/x-www-form-urlencoded”);
http_request.setRequestHeader(“Content-length”, parameters.length);
http_request.setRequestHeader(“Connection”, “close”);
http_request.send(parameters);

setTimeout(‘get()’,1000);
}

function alertContents() {
if (http_request.readyState == 4) {
if (http_request.status == 200) {
var sentID = http_request.responseText;

if (sentID != “”) {

var sessID = “<? echo $_SESSION[‘userID’]; ?>”;

if (sentID == sessID) {
self.location.reload();
}

}
} else {
alert(‘There was a problem with the request.’);
}
}
}

function get() {
var poststr = “userID=<? echo $_SESSION[‘userID’]; ?>”;
makePOSTRequest(‘server_mainlist.php’, poststr);
}
</script>

do anyone have any idea on this??
can actually ajax run on tomcat webserver??
pls tell me ..thanks alot~~

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@felgallAug 01.2006 — Try changing the code to get the session id from PHP to JSP.
×

Success!

Help @dethlon spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...