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?

  • What response precisely do you get for not logged in users?
    – Rarst
    Oct 6 '14 at 9:02
  • I get a blank page with no specific error I can catch
    – Meschiany
    Oct 6 '14 at 11:56
  • Completely blank, as in zero length content? WP_DEBUG enabled?
    – Rarst
    Oct 6 '14 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
    Oct 6 '14 at 12:12
  • You can see the body of Ajax responses using browser's dev tools. Nope, private isn't considered appropriate here.
    – Rarst
    Oct 6 '14 at 12:15

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.

  • Thank you, Changed to bauthor and bcat and still nothing.
    – Meschiany
    Oct 8 '14 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
    Aug 10 '18 at 5:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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