I have an AJAX request that retrieves information from a function I coded in my own plugin, here is how I set the ajax function:

function my_ajax_function () {

add_action('wp_ajax_do_ajax', 'my_ajax_function');

Complete file code at this link, will be temporarily available until we get a reply, I commented the line where the request fails, hope it helps:


In the jQuery script I'm able to do the AJAX call but it is returning nothing and it seems that my plugin is not loaded when calling the functions via AJAX, also I know the functions work correctly because I use them in other places in the website where they return the proper data, is there any configuration or something to do with this, so the plugin works with the AJAX requests?


  • do_action() does not return a value you could echo. Does it work when you echo a string? See also Debug AJAX.
    – fuxia
    Commented Jun 10, 2014 at 4:50
  • Well I was going to remove the echo because the function is simply not called.
    – Ultranuke
    Commented Jun 10, 2014 at 4:50
  • Why don’t you use your plugin function as a callback?
    – fuxia
    Commented Jun 10, 2014 at 4:53
  • Do you mean calling them directly? if yes, then I receive an error saying the function is not defined. :S
    – Ultranuke
    Commented Jun 10, 2014 at 4:56
  • Please add the complete code to your question. There is a logic error somewhere. :)
    – fuxia
    Commented Jun 10, 2014 at 4:57

1 Answer 1

//This is the function that fails when calling the function via an AJAX request.
$context['stories'] = apply_filters('xfwpint_get_slider_post_data', $context['stories']);

When calling via ajax , you have to include file in your ajax action function, file in which you have defined your filter, so it gets called.

For e.g.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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