Question

Here is the scenario:

My AJAX script determines whether or not a user is logged in when he clicks on an action. When the user is not logged in, AJAX returns error. I want to load div which contains login form on a fancybox.

How can I do this?

Here is what I have:

$.ajax({

    type : 'POST',
    url : 'xyz.action',
    dataType : 'text',
    herf :'login.jsp',
    success : function (data) {},
    error : function () {
        alert("PLEASE LOGIN");
        $("#loginForm").fancybox({
            'width'             : '75%',
             'height'           : '75%',
            'autoScale'         : false,
            'transitionIn'              : 'none',
            'transitionOut'             :  'none',
            'type'              : 'iframe'
        });

    }
});
return false;

Login

Was it helpful?

Solution

I got the solution :)...

$("#fan").fancybox({
        'enableEscapeButton' :true,
        'type':"iframe",
         href :'login.jsp',
        'hideOnOverlayClick' : true
      }).trigger('click');

OTHER TIPS

Try

$.fancybox('login.jsp');

If that doesn't work, I like to do this:

$.post('login.jsp',function(data){$.fancybox(data);});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top