Jump to content

Ajax in firefox 3.0.10


napsternapster

Recommended Posts

Hi ppl.

 

I'm validating two records entity type and name using ajax but my problem now is that it works well all other browsers except firefox.

 

var basiccounter ;

function ServerSideValidation(contact_counter,detailed_counter,f,selection,o_name)

{

basiccounter = 0;

   

//sending entity type to the server

var urlEntity = "entity_type.php";

urlEntity =  urlEntity+"?type="+document.getElementBYId(selection).value;

urlEntity = urlEntity+"&sid="+Math.random();

checkName(urlEntity,"GET", "sel_id", "lblEntity_error");

 

//sending official name to the server

var urlName="checkname.php";

urlName= urlName+"?q="+document.getElementBYId(o_name).value;

urlName = urlName+"&sid="+Math.random();

checkName(urlName,"GET", "txtOff_name", "lblOff_error");

   

      CheckErrors(f,basiccounter);

}

 

function checkName(url, method, id, label,f,detailed_counter)

{

var xmlhttp = new GetXmlHttp();

 

if(method == "GET")

{

xmlhttp.open(method, url, false);

xmlhttp.onreadystatechange = function()

{

if(xmlhttp.readyState == 4 && xmlhttp.status == 200)

 

  if(xmlhttp .responseText != 0)

  {

  basiccounter++;

  document.getElementById(label).innerHTML =  xmlhttp.responseText;

  document.getElementById(id).style.background = "pink"; 

  }

  else

  {

  document.getElementById(label).innerHTML = "";

  document.getElementById(id).style.background = "white"; 

  }

}

}

xmlhttp.send(null);

}

}

 

function CheckErrors(f,error)

{

if(error > 0 )

{

alert("found some errors on the serverside validation");

}

else

{

f.submit();

}

}

 

The code needs to function the same way in chrome,IE,opera,firefox and netscape

 

 

Link to comment
Share on other sites

Here is the GetXmlHttp function bellow

function GetXmlHttp()

{

// will store the reference to the XMLHttpRequest object

var xmlHttp;

// this should work for all browsers except IE6 and older

try

{

// try to create XMLHttpRequest object

xmlHttp = new XMLHttpRequest();

}

catch(e)

{

// assume IE6 or older

var XmlHttpVersions = new Array('MSXML2.XMLHTTP.6.0',

'MSXML2.XMLHTTP.5.0',

'MSXML2.XMLHTTP.4.0',

'MSXML2.XMLHTTP.3.0',

'MSXML2.XMLHTTP',

'Microsoft.XMLHTTP');

// try every prog id until one works

for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)

{

try

{

// try to create XMLHttpRequest object

xmlHttp = new ActiveXObject(XmlHttpVersions);

}

catch (e) {}

}

}

// return the created object or display an error message

if (!xmlHttp)

{

alert("Error creating the XMLHttpRequest object.");

}

else

{

return xmlHttp;

}

}

Link to comment
Share on other sites

Hi ppl.

 

I'm validating two records entity type and name using ajax but my problem now is that it works well all other browsers except firefox.

 

function GetXmlHttp()
{
// will store the reference to the XMLHttpRequest object
var xmlHttp;
// this should work for all browsers except IE6 and older
try
{
// try to create XMLHttpRequest object
xmlHttp = new XMLHttpRequest();
}
catch(e)
{
	// assume IE6 or older
	var XmlHttpVersions = new Array('MSXML2.XMLHTTP.6.0',
									'MSXML2.XMLHTTP.5.0',
									'MSXML2.XMLHTTP.4.0',
									'MSXML2.XMLHTTP.3.0',
									'MSXML2.XMLHTTP',
									'Microsoft.XMLHTTP');
	// try every prog id until one works
	for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
	{
		try
		{
			// try to create XMLHttpRequest object
			xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
		}
		catch (e) {}
	}
}
// return the created object or display an error message
if (!xmlHttp)
{
	alert("Error creating the XMLHttpRequest object.");
}
else
{
	return xmlHttp;
}
}

var basiccounter ;
function ServerSideValidation(contact_counter,detailed_counter,f,selection,o_name)
{
   basiccounter = 0;
     
   //sending entity type to the server
   var urlEntity = "entity_type.php";
   urlEntity =   urlEntity+"?type="+document.getElementBYId(selection).value;         
   urlEntity = urlEntity+"&sid="+Math.random();
   checkName(urlEntity,"GET", "sel_id", "lblEntity_error");
   
   //sending official name to the server
   var urlName="checkname.php";
   urlName= urlName+"?q="+document.getElementBYId(o_name).value;         
   urlName = urlName+"&sid="+Math.random();
   checkName(urlName,"GET", "txtOff_name", "lblOff_error");
     
       CheckErrors(f,basiccounter);
}

function checkName(url, method, id, label,f,detailed_counter)
{
   var xmlhttp = new GetXmlHttp();
   
   if(method == "GET")
   {
      xmlhttp.open(method, url, false);
      xmlhttp.onreadystatechange = function()
      {
         if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
         { 
         
            if(xmlhttp .responseText != 0)
            {
               basiccounter++;
               document.getElementById(label).innerHTML =  xmlhttp.responseText;
               document.getElementById(id).style.background = "pink"; 
            }
            else
            {
               document.getElementById(label).innerHTML = "";
               document.getElementById(id).style.background = "white"; 
            }
         }
      }
      xmlhttp.send(null);   
   }
}

function CheckErrors(f,error)
{
      if(error > 0 )
      {
         alert("found some errors on the serverside validation");
      }
      else
      {   
         f.submit();
      }
}


The code needs to function the same way in chrome,IE,opera,firefox and netscape

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.