Hi,

Recently I'm trying to implement a simple Django application that
include one server side AJAX validation, it's a simple form input
field (username). I have used a pre-built in line AJAX validation
mechanism which uses jQuery. So the code goes like this

HTML snippet

<form id="simpleform" method="post" action="/done/">

Username:<input value=""
class="validate[required,custom[noSpecialCaracters],length[0,20],ajax[ajaxUser]]"
type="text" name="user" id="user" />

<input class="submit" type="submit" value="Validate"/>
</form>

The server side code snippet (embedded in to a php script)

/* RECEIVE VALUE */
$validateValue=$_POST['validateValue'];
$validateId=$_POST['validateId'];
$validateError=$_POST['validateError'];

    /* RETURN VALUE */
    $arrayToJs = array();
    $arrayToJs[0] = $validateId;
    $arrayToJs[1] = $validateError;

if($validateValue =="testname"){        // validate??
    $arrayToJs[2] = "true";         // RETURN TRUE
    echo
'{"jsonValidateReturn":'.json_encode($arrayToJs).'}';          //
RETURN ARRAY WITH success
}else{
    for($x=0;$x<1000000;$x++){
        if($x == 990000){
            $arrayToJs[2] = "false";
            echo
'{"jsonValidateReturn":'.json_encode($arrayToJs).'}';      // RETURN
ARRAY WITH ERROR
        }
    }

}

So I have some questions to ask from you people

How do I get the user name from the input field in to the back end?(in
order to use in Django environment)

Do I need to get JSON support in Python?

I think the server side script snippet already does a big part
(passing the value to the backend as a JSON object) but I want to know
how to use this in my Python code,and this is my first time using
jQuery and I do need to use this same exact validation library. Your
valuable corporation is expected.

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to