I've been working on this for three days and can't for
the life of me figure out the best solution.

I have a login area on every page. My (old but
working) code is the following:

$("div#login input#login_btn").click(function() {
$.ajax({
        type: "POST",
        url: "/users/login.php",
        data: ("login=1&username=" + username + "&password="
+ pw),
        dataType: "html",
        success: function(msg){ 
                        window.location.reload(true); 
                    }, 
        async: false
        });
        return false;
});     

Note that I don't have any error handling hooked up.
On login.php, it sets a cookie; then, when the page
reloads, it sees the cookie and shows the logout form
instead.

I now want to do two things: hook up Mike's form
plugin, and Jorn's validator. I saw the example at the
validator demo page for it + ajax but can't figure out
how to customize it for what I need. 

I tried implementing this:

$("#loginform").validate({
        submitHandler: function(form) {
        jQuery(form).ajaxSubmit({
                                                dataType: "html",
        success: function(json) {
                                                        if(result.status) {     
                
v.showErrors(result.data);}     
                                                        else    {
                                                                
window.location.reload(true); 
        }

                        }                                       });
        }
});

This doesn't work, but I can't say I'm surprised. I
don't understand JSON (usually just use
HTML/responsetext), but don't know how to get this to
work with it. 

Things I need:

1. validation to be done before ajaxform/submit is
called (right now it's basic -- make sure
username/password is populated). I can get this to
work with plain old validator (no ajax used)

2. validation errors from login.php to be outputted if
there are any (specifically, if the username/password
don't work, I have a generic error message I need to
pass back to display)

3. window.reload to be called if everything worked

I know this is a vague request, but can anyone help me
out? Arrgh, I have to have this done by Thursday and
am about ready to throw my monitor through the window
:(

thanks,
-kim





 
____________________________________________________________________________________
It's here! Your new message!  
Get new email alerts with the free Yahoo! Toolbar.
http://tools.search.yahoo.com/toolbar/features/mail/

Reply via email to