Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. <a onclick="show_trend()" >Trend</a>
  2.  
  3. function show_trend() {
  4.  
  5. // This does the ajax request
  6. $.ajax({
  7. url: ajaxurl,
  8. data: {
  9. 'action':'render_admin_charts_page',
  10.  
  11. },
  12. success:function(data) {
  13. // This outputs the result of the ajax request
  14. console.log(data);
  15. },
  16. error: function(errorThrown){
  17. console.log(errorThrown);
  18. }
  19. });
  20. }
  21.  
  22. function render_admin_charts_page() {
  23. ?>
  24. <div class="wrap">
  25. <div class="em-bookings-events">
  26. <h2><?php esc_html_e('Event Booking Report','dbem'); ?></h2>
  27. <?php em_bookings_events_table(); ?>
  28.  
  29. </div>
  30. </div>
  31. <?php
  32. }
  33.  
  34. add_action( 'wp_ajax_render_admin_charts_page', 'yourfunction' );
  35.  
  36. function yourfunction() { ?>
  37. <div class="wrap">
  38. <div class="em-bookings-events">
  39. <h2><?php esc_html_e('Event Booking Report','dbem'); ?></h2>
  40. <?php em_bookings_events_table(); ?>
  41. </div>
  42. </div>
  43. <?php // Handle request then generate response using WP_Ajax_Response
  44. }
  45.  
  46. jQuery.post(
  47. ajaxurl,
  48. {
  49. 'action': 'render_admin_charts_page',
  50. },
  51. function(response){
  52. alert('The server responded: ' + response);
  53. }
  54. );
  55.  
  56. add_action( 'wp_ajax_render_admin_charts_page', 'yourfunction' );
  57.  
  58. function yourfunction() { ?>
  59. <div class="wrap">
  60. <div class="em-bookings-events">
  61. <h2><?php esc_html_e('Event Booking Report','dbem'); ?></h2>
  62. <?php em_bookings_events_table(); ?>
  63. </div>
  64. </div>
  65. <?php // Handle request then generate response using WP_Ajax_Response
  66. }
  67.  
  68. jQuery.ajax({
  69. url: fav_url , // path of that file
  70. type: 'GET',
  71. timeout: 20000,
  72. error: function(){
  73. alert("Error loading user's attending event.");
  74. },
  75. success: function(html){}
  76. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement