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
https://forums.phpfreaks.com/topic/168103-ajax-in-firefox-3010/
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
https://forums.phpfreaks.com/topic/168103-ajax-in-firefox-3010/#findComment-886628
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
https://forums.phpfreaks.com/topic/168103-ajax-in-firefox-3010/#findComment-886635
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.