redirect on successful jquery form plugin submit

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

redirect on successful jquery form plugin submit

Alex-484

I am using the jquery form plugin as part of login.  When the form is
submitted a php file checks to make sure the credentials are correct
and either returns "success" or "error"

my post-submit callback function is

function showResponse(responseText, statusText)  {
                $('form#login #loginresults').html("").hide();

                if (responseText == "success") {
                        window.location="myaccount.php";
                }
                if (responseText == "error") {
                        $('form#login #loginresults').html('<img src="img/bigerror.png"
alt="form error" /> <span id="formsuccess">Login / Password are not
valid.</span>').slideDown();
                }
        }


What I want to do is if there is an error display a div showing an
error message, but if the login was correct I want to redirect the
user to another page "myaccount.php".

I thought the window.location command would redirect the page but it
does nothing.  I have also tried using header(location:
"myaccount.php") in my php file but that just loads the site in the
notification div.

How do I just redirect the user to another page?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery Plugins" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/jquery-plugins?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: redirect on successful jquery form plugin submit

Alex-484

Actually it wasn't a problem with the jquery at all.  my php function
wasn't returning what I though it was and it is all working fine now.

On Jan 21, 12:22 pm, Alex <[hidden email]> wrote:

> I am using the jquery form plugin as part of login.  When the form is
> submitted a php file checks to make sure the credentials are correct
> and either returns "success" or "error"
>
> my post-submit callback function is
>
> function showResponse(responseText, statusText)  {
>                 $('form#login #loginresults').html("").hide();
>
>                 if (responseText == "success") {
>                         window.location="myaccount.php";
>                 }
>                 if (responseText == "error") {
>                         $('form#login #loginresults').html('<img src="img/bigerror.png"
> alt="form error" /> <span id="formsuccess">Login / Password are not
> valid.</span>').slideDown();
>                 }
>         }
>
> What I want to do is if there is an error display a div showing an
> error message, but if the login was correct I want to redirect the
> user to another page "myaccount.php".
>
> I thought the window.location command would redirect the page but it
> does nothing.  I have also tried using header(location:
> "myaccount.php") in my php file but that just loads the site in the
> notification div.
>
> How do I just redirect the user to another page?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "jQuery Plugins" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.com/group/jquery-plugins?hl=en
-~----------~----~----~----~------~----~------~--~---