SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Zealot
    Join Date
    Feb 2007
    Location
    Leeds, U.K.
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript halts in ie 6/7

    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...eckregister.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";
    	}
    				
    }
    		
    }
    thanks

  2. #2
    SitePoint Zealot
    Join Date
    Feb 2007
    Location
    Leeds, U.K.
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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

  3. #3
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't see anything wrong at first sight but you have some redundant code.

    The less code you have the less chance of bugs.

  4. #4
    SitePoint Zealot
    Join Date
    Feb 2007
    Location
    Leeds, U.K.
    Posts
    127
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    cheers M M J, I have searched through the script, and just re wrote it. Seems to work now, even though all the same components are there haha.

    thanks again

  5. #5
    SitePoint Addict
    Join Date
    Dec 2007
    Posts
    207
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol, your welcome.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •