Connecting Tech Pros Worldwide Help | Site Map

can't call the servlet using AJAX

  #1  
Old July 18th, 2006, 11:25 PM
sk
Guest
 
Posts: n/a
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()
{}


  #2  
Old July 19th, 2006, 03:05 AM
Randy Webb
Guest
 
Posts: n/a

re: can't call the servlet using AJAX


sk said the following on 7/18/2006 6:34 PM:
Quote:
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.
Quote:
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/
Closed Thread


Similar Threads
Thread Thread Starter Forum Replies Last Post
ajax and js not working together!! ashwinkumar18 answers 16 September 19th, 2008 03:39 AM
Ajax call returning prematurily Simon_21 answers 4 March 20th, 2008 08:05 PM
Help needed on JavaScript and Ajax.. DurgaKar1780 answers 2 February 13th, 2007 08:49 AM
permission denied when using XMLHttpRequest in mozilla robi answers 0 February 20th, 2006 09:07 AM