Jump to content

I f*****g E is stupid and doesn't like me XD


Recommended Posts

This works fine in FF and there JS debugger finds no problems, whereas in IE if i enter 3+ chars it does nothing and just says error on page , then runtime error :s

 

Any ideas please?

 

Site is

http://www.americangangsters.org/find.php

 

User: Test

Pass: tester

 

 

<script type="text/javascript">
var xmlHttp=null;

function GetXmlHttpObject()
{
try
{
	// Firefox, Opera 8.0+, Safari
	xmlHttp=new XMLHttpRequest();
}
catch (e)
{
	// Internet Explorer
	try
	{
		xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch (e)
	{
		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
}
return xmlHttp;
}

function stateChanged() 
{ 
document.getElementById("Js").innerHTML = '<td colspan="2" id="SearchResults"></td>';

document.getElementById("SearchResults").innerHTML = "<img align='middle' src='./images/loading.gif'/>";

if (xmlHttp.readyState == 4)
{ 
	document.getElementById("SearchResults").innerHTML = xmlHttp.responseText;
}
}

function trim(str)
{
var s;
s = str.replace(/^(\s)*/, '');
s = s.replace(/(\s)*$/, '');
    return s;
}


function UserSearch(Find)
{

Find = trim(Find);

if(Find.length == 0)
{
	document.getElementById("Warning").innerHTML = "";
	if(document.getElementById("SearchResults") != null)
	{
		if(document.getElementById("SearchResults").innerHTML  == "<img align='middle' src='./images/loading.gif'/>")
		{
			document.getElementById("Js").innerHTML = '';

			document.getElementById("SearchResults").innerHTML = "";
		}
	}
	return;
}
else if(Find.length < 3)
{ 
	document.getElementById("Warning").innerHTML = "Enter 3 or more characters to begin searching";
	if(document.getElementById("SearchResults") != null)
	{
		if(document.getElementById("SearchResults").innerHTML  == "<img align='middle' src='./images/loading.gif'/>")
		{
			document.getElementById("Js").innerHTML = '';

			document.getElementById("SearchResults").innerHTML = "";
		}
	}
	return;
}
else
{
	document.getElementById("Warning").innerHTML = "";

	xmlHttp = GetXmlHttpObject();

	if (xmlHttp==null)
	{
		alert ("Your browser does not support AJAX!, Please consider updating your browser");
		return;
	} 

	var url="./Ajax/FindUser.php?user="+Find;
	xmlHttp.onreadystatechange = stateChanged;
	xmlHttp.open("GET",url,true);
	xmlHttp.send(null);
}
}

function ChangeSearch(type)
{
if(type == true)
{
	document.getElementById("users_username").attributes["onkeyup"].value = "UserSearch(this.value)";	
	docuemnt.getElementById("form1").attributes["action"].value = "";
	document.getElementById("form1").attributes["onsubmit"].value = "";
}
else
{
	document.getElementById("users_username").attributes["onkeyup"].value = "";	
	document.getElementById("form1").attributes["action"].value = "javascript:void()";
	document.getElementById("form1").attributes["onsubmit"].value = "UserSearch(document.form1.users.value)";
}
}

function Init()
{
document.getElementById("js").innerHTML = 'Search While Typing <input type="checkbox" checked="checked" onchange="ChangeSearch(this.checked)">';
}
</script>
</head>
<body onload="Init()">

Link to comment
Share on other sites

try this instead:

 

function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

Link to comment
Share on other sites

At the top

function GetXmlHttpObject()
{
   try
   {
      // Firefox, Opera 8.0+, Safari
      xmlHttp=new XMLHttpRequest();
   }
   catch (e)
   {
      // Internet Explorer
      try
      {
         xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
      catch (e)
      {
         xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
   }
   return xmlHttp;
}

 

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.