By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,946 Members | 1,610 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,946 IT Pros & Developers. It's quick & easy.

can't call the servlet using AJAX

P: n/a
sk
I create some javascript to send some search request.
However, on some machines i wont' be able to send
request. What could be the reason?

function sendSearchRequest()
{
var srch_url = "/servlet/Search";
try {
request = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = null;
}
}
}

request.open('GET', srch_url , true );
request.onreadystatechange = GetSearchResponse;
request.send(null);
}

function GetSearchResponse()
{}
Jul 18 '06 #1
Share this Question
Share on Google+
1 Reply


P: n/a
sk said the following on 7/18/2006 6:34 PM:
I create some javascript to send some search request.
However, on some machines i wont' be able to send
request. What could be the reason?
Several.

The browser doesn't support the HTTPRequest Object.
The browser doesn't allow ActiveX.
You are using limited HTTPRequest code.
function sendSearchRequest()
{
var srch_url = "/servlet/Search";
try {
request = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = null;
If the browser doesn't support Msml2.XMLHTTP or Microsoft.XMLHTTP then
your code fails silently. There are MSIE's with other versions of
XMLHTTP support and no non-IE browser supports your code.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Temporarily at: http://members.aol.com/_ht_a/hikksnotathome/cljfaq/
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 19 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.