[eluser]aidehua[/eluser]
I figured it out, I think.
I changed the Ajax open method from GET to POST, so I now send the username, with or without non-alphanumeric characters, in the POST parameters. Then I can clean it up on the server without worrying about using client-side Javascript to make it URI-compliant.
Here's the Javascript I ended up with
Code:
var user = document.getElementById('username').value;
if (user!=''){
url = "<?= base_url() ?>ajax/checkusernameexists/";
var parameters = "user=" + user;
ajaxRequest.open("POST", url, true);
ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
ajaxRequest.send(parameters)
ajaxRequest.send(null);
}
Seems to work fine. Obvious, really, once you think of it.