Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $(function() {
- console.log( "ready!" );
- $('.btn-loved').on('click', function (e){
- e.preventDefault();
- var btn = $(this);
- var state = btn.attr('data-active'); //btn.data('active');
- if(state=='true') to_do = 'unset';
- else to_do = 'set';
- console.log(to_do)
- //to_do = (state=='active') ? 'unset':'set';
- $.ajax({
- 'method': 'post',
- 'url': 'http://localhost/twitter/server/api.php',
- 'data':{ action: to_do, dataset: 'love', id: 123 },
- 'cache':false
- }).done(function(response) {
- console.log(response);
- var r = $.parseJSON(response);
- switch(r.newstate)
- {
- case 'active':
- btn.attr('data-active', 'true');
- btn.find('span').html(r.number);
- btn.find('i').removeClass('far').addClass('fas').css('color', '#c00');
- break;
- default:
- btn.attr('data-active', 'false');
- btn.find('span').html(r.number);
- btn.find('i').removeClass('fas').addClass('far').css('color', '');
- break;
- }
- }).fail(function(response) {
- console.error(response);
- })
- });
- $('#LogInButton').on('click', function (e){
- console.log( "bell!" );
- e.preventDefault();
- var f = $("#login-form");
- var username = f.find('#username').val();
- var password = f.find('#password').val();
- $.ajax({
- 'method': 'post',
- 'url': 'http://localhost/twitter/server/api.php',
- 'data':{ action: 'auth', username: username, password: password },
- 'cache':false
- }).done(function(response) {
- console.log( "credenziali inviate!" );
- }).fail(function(response) {
- console.error(response);
- })
- });
- $('#LogInButton').on('click', function (e){
- console.log( "bell!" );
- e.preventDefault();
- var f = $("#login-form");
- var username = f.find('#username').val();
- var password = f.find('#password').val();
- $.ajax({
- 'method': 'post',
- 'url': 'http://localhost/twitter/server/api.php',
- 'data':{ action: 'auth', username: username, password: password },
- 'cache':false
- }).done(function(response) {
- console.log( "credenziali inviate!" );
- }).fail(function(response) {
- console.error(response);
- })
- });
- $('button.btn-comment').on('click', function(){
- $("#replyModal").modal();
- });
- $('#login-btn').on('click', function(){
- $("#logInModal").modal();
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement