This code works fine when running in IE. I get a request asking to allow blocked content due to the use of activeX. But when I run it in firefox and other browsers.. I get nothing. Kindly help.
var httpRequest;
try
{
httpRequest = new XMLHttpRequest(); // Mozilla, Safari, etc
}
catch(trymicrosoft)
{
try
{
httpRequest = new ActiveXObject("Msxml2.XMLHTTP");
}
catch(oldermicrosoft)
{
try
{
httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
}
catch(failed)
{
httpRequest = false;
}
}
}
if(!httpRequest)
{
alert('Your browser does not support Ajax.');
return false;
}
//===============================
// Action http_request
var finaltxt;
//do{
httpRequest.onreadystatechange = function()
{
if(httpRequest.readyState == 4)
if(httpRequest.status == 200)
{
var txt = httpRequest.responseText;
var index = txt.search(/regular/i);
var index1 = txt.search(/to see hours/i);
finaltxt = txt.substring(index,index1);
document.write("<IMG " +"SRC='web2.jpg'>");
document.write("<br>"+ finaltxt.fontsize(2) + "<br>");
return finaltxt;
}
else
return finaltxt;
}
httpRequest.open('GET','http://xyz',true);
httpRequest.send(null);
return finaltxt;
switch to use a javascript library like jquery that supports multi=browser support.. you will never have to write code like this again..
see the ajax api in particular.
Check out jquery