0

I know that this issue has been discussed many times, but I think I tried most of the advises.

This is my code:

$.post('<?php echo admin_url( 'admin-ajax.php' ) ?>', 
    {'action': 'load_posts',
     'offset': offset,
     'author' : <?php echo $uid?>,
     'cat'  : '<?php echo $category->name?>',
     'color': '<?php echo get_cat_color($category->cat_ID)?>' 
    },  function(response){
        if (response.trim() == ""){$("#more_posts_<?php echo $catNoSpace?>").hide();}
           $("#cat<?php echo $catNoSpace?>").append("<div class='newdiv'>" + response + "</div>");
        }

And I have these both lines:

add_action('wp_ajax_load_posts', 'ng_load_posts');

add_action('wp_ajax_nopriv_load_posts', 'ng_load_posts');

And a well working ng_load_posts() function.

Also I tried to disable all of my installed plugins.

What am I missing?

10
  • What response precisely do you get for not logged in users?
    – Rarst
    Commented Oct 6, 2014 at 9:02
  • I get a blank page with no specific error I can catch
    – Meschiany
    Commented Oct 6, 2014 at 11:56
  • Completely blank, as in zero length content? WP_DEBUG enabled?
    – Rarst
    Commented Oct 6, 2014 at 12:05
  • Even if I get something, how can I catch it? in console it is blank. yes the wp_debug is enabled May I send you additional info in private?
    – Meschiany
    Commented Oct 6, 2014 at 12:12
  • You can see the body of Ajax responses using browser's dev tools. Nope, private isn't considered appropriate here.
    – Rarst
    Commented Oct 6, 2014 at 12:15

1 Answer 1

0

There are some "magic" request parameters that are better avoided, mostly anything that can be used as a parameter name at a request url but also some more like "email" (don't think it is well documented and a quick google failed to bring a good reference).

Try to change the names of your parameters especially the "author" and "cat", maybe just add some prefix to them.

2
  • Thank you, Changed to bauthor and bcat and still nothing.
    – Meschiany
    Commented Oct 8, 2014 at 7:56
  • before making ajax event, enable console log in chrome for errros. And also change '<?php echo admin_url( 'admin-ajax.php' ) ?>' to '<?php echo admin_url( "admin-ajax.php" ) ?>'. Try this luck!
    – Balas
    Commented Aug 10, 2018 at 5:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.