I ask for advice on jQuery
Good day to all!
I learn jQuery and write ajax authorization for my site. jQuery is a great framework. I do not understand javascript and it is unlikely that I could write ajax authorization on it. Thanks to jQuery for such a wonderful miracle!
Below I have given the authorization code. In general, everything works correctly, but after the user has logged in, then by clicking on the "Exit" link the loginout event does not occur, and if you reload the page, it will work. The same thing after the user logs out - without reloading the page, he will no longer be able to log in. Maybe someone will tell you how to solve the problem?
I will also be grateful for the comments and comments on the code.
I learn jQuery and write ajax authorization for my site. jQuery is a great framework. I do not understand javascript and it is unlikely that I could write ajax authorization on it. Thanks to jQuery for such a wonderful miracle!
Below I have given the authorization code. In general, everything works correctly, but after the user has logged in, then by clicking on the "Exit" link the loginout event does not occur, and if you reload the page, it will work. The same thing after the user logs out - without reloading the page, he will no longer be able to log in. Maybe someone will tell you how to solve the problem?
I will also be grateful for the comments and comments on the code.
- $(document).ready(function(){
- //ajax login
- $("#loginform").bind("submit",function() {
- var qString = $('#loginform').formSerialize();
- $.getJSON('login.html', qString, function(json){
- if(json.result == 1){
- $('#login').html('');
- $('#login').append('' + json.login + ' Выход');
- $("#logout").bind("click",function() {
- $('#login').load("logout.html");;
- return false;
- });
- } else {
- $('#msg').html('');
- $('#msg').append('Неверно введён логин или пароль');
- }
- });
- return false;
- });
- //end ajax login
- //ajax logout
- $("#logout").bind("click",function() {
- $('#login').load("logout.html");
- return false;
- });
- //end ajax logout
- });
- //end document.ready
* This source code was highlighted with Source Code Highlighter.