Created
June 16, 2014 19:39
-
-
Save brhoades/0ff8530c09c38ee6c71b to your computer and use it in GitHub Desktop.
jQuery Embedded Anonymous FUNctions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ajax get the upvote click | |
jQuery( document.getElementsByClassName( "up_count" ) ).bind( 'click', function( event ){ | |
jQuery( '#vmp_message' ).empty(); | |
jQuery.ajax( { | |
url:ajax_object.ajax_url, | |
method:'get', | |
dataType:'json', | |
data:{ | |
action:'count_vote_090813', | |
post_id: event.target.parentNode.lastChild.innerHTML, | |
type:'upvote' | |
}, | |
success:function( response ){ | |
jQuery( '#vmp_message_panel' ).animate( { 'top': '50px' } ).delay( 3000 ); | |
if ( 'error' == response.type ){ | |
jQuery( '#vmp_message' ).html( response.html ).css( 'background-color', 'red' ); | |
}else if( 'success' == response.type ){ | |
jQuery( '#vmp_up_counter' ).html( response.html ); | |
jQuery( '#vmp_message' ).html( "Successfully registered vote" ); | |
}else{ | |
jQuery( '#vmp_message' ).html( "An unknown error has occured. Check your connection." ).css( 'background-color', 'green' ); | |
} | |
jQuery( '#vmp_message_panel' ).animate( { 'top': '0px' }, 500, 'swing', | |
function() { jQuery( '#vmp_message' ).empty( ) } ); | |
} | |
} ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment