Dynadot โ€” .com Registration $8.99

Javascript just stops in IE

Spaceship Spaceship
Watch

Albino

Munky DesignsEstablished Member
Impact
17
I am just tweaking my register script, and ive realised it halts in ie (both 6 and 7), but is fine in ff and opera.

http://munkydesigns.co.uk/ScriptsNew/register.php

thats the page. when you fill in a name, it works ok, as soon as you fill in a password/email, it just halts on checking.

anyone any idea why this is happening?

you can see the .js file here:

http://munkydesigns.co.uk/ScriptsNew/scripts/js/checkregister.js

and the code to check the username is:

Code:
function checkName($username, $usernameActual = ""){

$u = @strtolower($this->strip($username));
$u2 = @strtolower($this->strip($usernameActual));
$result = @mysql_query("SELECT * FROM users WHERE username = '".$u."' LIMIT 1")or die(mysql_error());
$count = @mysql_num_rows($result);
$r = @mysql_fetch_assoc($result);

if ($count == 0){
			
	return "Name available";
				
}else{
	//If you are editing a user on the admin section
	if (($this->checkAdmin()) && ($u == $u2)){
		return "Name available";
	}else{
		return "Name taken";
	}
				
}
		
}

as usual, reps for help and all that!
thanks :)
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
ok, ive done a load of debugging, and I think its something to do with the ajax script. It will do the functions once, but thats it, it won't do them again. Try to do it twice, and it halts.

the ajax code is:

Code:
var req;
	if (window.XMLHttpRequest)
    {
        // browser has native support for XMLHttpRequest object
        req = new XMLHttpRequest();
    }
    else if (window.ActiveXObject)
    {
        // try XMLHTTP ActiveX (Internet Explorer) version
        req = new ActiveXObject("Microsoft.XMLHTTP");
    }


var nextfunct;

function ajaxPost(method, url, toSend, responseHandler, msgDiv, msg)
{
    if(req)
    {
		showpleasewait(msgDiv, msg);
		nextfunct = responseHandler;
        req.onreadystatechange = function() {postajax(msgDiv)};
        req.open(method, url, true);
        req.setRequestHeader("content-type","application/x-www-form-urlencoded");
		req.setRequestHeader("Content-length", toSend.length);
		req.setRequestHeader("Connection", "close");
        req.send(toSend);
		alert("here2"+toSend);
		alert(req);
    }
    else
    {
        alert('Your browser does not seem to support XMLHttpRequest.');
    }
}

function postajax(msgDiv){
	if (req.readyState == 4) {
		hidepleasewait(msgDiv);
		nextfunct();
	}
}

function showpleasewait(msgDiv, msg){
		document.getElementById(msgDiv).innerHTML = msg;
}

function hidepleasewait(msgDiv){
	document.getElementById(msgDiv).innerHTML = "";
}

as you can see, ive added in some random alerts to see where it gets up to. now, it does all the one here, but the function never gets there.

so

req.send(toSend);

isn't sending.

i've tried new XHTML requests, ive tried clearng the cache in the check name output, but to no avail :(
 
0
•••
The AJAX should be like this for compatibiliy with IE:

PHP:
<script language="javascript" type="text/javascript">
<!-- 
//Browser Support Code
function ajaxFunction(){
	var ajaxRequest;  // The variable that makes Ajax possible!
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
}

//-->
</script>
 
1
•••
cheers TGN, I actually added that last night.

it still didn't help, so I completely remade the script (well copied and pasted it all back in 1 by one), and now it works :S

thanks though!
 
0
•••
Unstoppable Domains
Domain Recover
DomainEasy โ€” Live Options
  • The sidebar remains visible by scrolling at a speed relative to the pageโ€™s height.
Back