When form is submited automatically close fancybox and reload the page

5,447 views
Skip to first unread message

Levani Melikishvili

unread,
Jun 29, 2010, 5:01:42 AM6/29/10
to fancybox
I'm using fancybox to open login form in popup... I want to
automatically close fancybox if the login is success and reload the
page...

Is that possible?

Thanks

zero

unread,
Jun 29, 2010, 7:42:03 AM6/29/10
to fancybox
In theory (since i've never tried it) you could do it with AJAX.

Fancybox opens with login box

User presses submit and you check via ajax if the login details is
correct.

If they are not display something to warn the user.. else.. Log him in
via AJAX i guess, do a "$.fancybox.close()" with Javascript and also
reload the page again with javascript.

But like i said.. This is the theory :P

Here are a few links for the PHP/Ajax code that might help.

Fancybox BLOG (look at No5) http://fancybox.net/blog


(just googled)

http://roshanbh.com.np/2008/04/ajax-login-validation-php-jquery.html
http://www.bitrepository.com/ajax-login-form.html

liyam

unread,
Jul 28, 2010, 10:19:06 AM7/28/10
to fancybox
I've been trying to develop a script for this and so far I was able to
find a working but nasty solution:

On the parent page, you should have the function parent location:

$(".varID").fancybox({
'type' : 'iframe',
'overlayShow' : false,
'hideOnOverlayClick' : false,
'hideOnContentClick': false,
'onClosed': function() { parent.location.reload(true); ; }
});


Then what you need is another close function that has a timer and that
will initialize the parent page.

php condition here something like:

if login successful {

<script type="text/javascript" src="http://code.jquery.com/
jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="fancybox/
jquery.fancybox-1.3.1.js"></script>
</head>
<body onload="setTimeout ('parent.$.fancybox.close ()', 2000); ">
login successful
</body>
</html>

} else {
login here [username text field]
}


Sorry, I can't find the site where I found this solution. Thanks to
whoever was the actual brains of this script


On Jun 29, 7:42 pm, zero <z...@zerodesign.gr> wrote:
> In theory (since i've never tried it) you could do it with AJAX.
>
> Fancybox opens with login box
>
> User presses submit and you check via ajax if the login details is
> correct.
>
> If they are not display something to warn the user.. else.. Log him in
> via AJAX i guess, do a "$.fancybox.close()" with Javascript and also
> reload the page again with javascript.
>
> But like i said.. This is the theory :P
>
> Here are a few links for the PHP/Ajax code that might help.
>
> Fancybox BLOG (look at No5)http://fancybox.net/blog
>
> (just googled)
>
> http://roshanbh.com.np/2008/04/ajax-login-validation-php-jquery.htmlhttp://www.bitrepository.com/ajax-login-form.html
>

Sisira Kumara

unread,
Nov 16, 2012, 2:19:07 AM11/16/12
to fanc...@googlegroups.com
Great..! thanks
Reply all
Reply to author
Forward
0 new messages