can't call the servlet using AJAX

S

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()
{}
 
R

Randy Webb

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,608
Members
45,250
Latest member
Charlesreero

Latest Threads

Top