0

I need to implement login in popup window, but if user is already login window should be closed. After login process window sholud also be closed.I'm using jQuery. Should I use ajax? Can someone provide me an example?

Bohdan Myslyvchuk
  • 1,657
  • 3
  • 24
  • 39

1 Answers1

1

use bootstrap model see this example and use ajax for login.

Example: http://jsfiddle.net/kevalbhatt18/n61n2ujk/6/

bootstrap login them

And for switch button like login or logout use flag.

var login = false;

login?($('#login').hide(),$('#logout').show()):($('#login').show(),$('#logout').hide())

Just change flag and it will show you logout button

And this is ajax :

$("#form").submit(function(){

   var formdatatest= $("#form").serializeArray()
  $.ajax({
   type: "POST",
   url: "/your/url",
    data: formdatatest,
   success: function(html){    


   },
   error:function()
   {

   }
  });
return false;
});

How do I return the response from an asynchronous call?

See above link because when you use ajax call and you are returning or calling ajax function from some where else then it will return undefined so in that case refer above link or if you do some your task in success call back and returning nothing then you don't need to vary

Community
  • 1
  • 1
Keval Bhatt
  • 6,224
  • 2
  • 24
  • 40
  • The problem is that in pop up window I'm opening login page of other website. And I need to know whether I logged in or not. If I logged than window should be automaticaly closed. Can check with ajax if i loged on website? – Bohdan Myslyvchuk Jul 02 '15 at 11:20