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?
Asked
Active
Viewed 1,428 times
0
-
What server platform are you using? – 3-14159265358979323846264 Jul 02 '15 at 10:40
-
@3-14159265358979323846264 I'm using java, if you mean that – Bohdan Myslyvchuk Jul 02 '15 at 10:49
-
check this out http://stackoverflow.com/questions/11363732/how-to-get-input-via-a-popup-and-place-text-in-a-variable-via-javascript-jquery – JammuPapa Jul 02 '15 at 10:55
1 Answers
1
use bootstrap model see this example and use ajax for login.
Example: http://jsfiddle.net/kevalbhatt18/n61n2ujk/6/
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