Created
April 22, 2014 12:13
-
-
Save gicolek/11176527 to your computer and use it in GitHub Desktop.
Trigger View
This file contains hidden or 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
| <script> | |
| function trigger_view(id) { | |
| jQuery.post( | |
| <?php echo json_encode( 'some_url' ) ?>, | |
| { | |
| // a post id, fetched before | |
| "cp_post_id": id, | |
| // wordpress nonce for safety reason | |
| "nonce": '<?php echo wp_create_nonce( 'view' ); ?>' | |
| } | |
| ).done(function() { | |
| // log some data | |
| console.log('Post ' + id + ' viewed.'); | |
| }); | |
| } | |
| ; | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment