Welcome Guest, Not a member yet? Register   Sign In
Passing non-alphanumeric characters as parameters to a function in a Controller
#2

[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.


Messages In This Thread
Passing non-alphanumeric characters as parameters to a function in a Controller - by El Forum - 11-01-2009, 06:48 PM



Theme © iAndrew 2016 - Forum software by © MyBB