Advertisement
Guest User

Untitled

a guest
Aug 22nd, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function get_category_name(category) {
  2.      // We'll pass this variable to the PHP function seo_ajax_request
  3.     // This does the ajax request
  4.     var cat_slug = category;
  5.     jQuery.ajax({
  6.         url: seo_ajax_obj.ajaxurl, // or example_ajax_obj.ajaxurl if using on frontend
  7.         data: {
  8.             'action': 'seo_ajax_request',
  9.             'category' : cat_slug
  10.         },
  11.         success:function(data) {
  12.             // This outputs the result of the ajax request
  13.             console.log(JSON.parse(data));
  14.             return JSON.parse(data);
  15.         },
  16.         error: function(errorThrown){
  17.             console.log(errorThrown);
  18.         }
  19.     });              
  20. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement