ajax recursive calls on wordpress returning answers outsite the function scope

I’m having a problem when i use an ajax function where it is used with this:

window.setInterval(liveDrop, 2000);

This trigger my ajax call every 2 secounds and check if is there is need to update something in the site.

The function works fine, but when i put something like this on functions.php(not only this, but as exemple)
echo ‘TEST’;
my ajax request runned in window.setInterval start to print this ‘test’, and this ‘echo teste’ is actually outsite the function scope on ‘action:my_function’ in the ajax request.

My problem is that, i receiving outsite commands in my ajax calls.

Addicional information:
i’m using wp_die(), wp_send_json_success.. etc
I’m register my functions in the right hooks( they work fine if don’t have a echo ‘test’ or anything in ‘admin_init_hook’)

Has anyone ever seen this happen?

Read more here:: ajax recursive calls on wordpress returning answers outsite the function scope

Leave a Reply

Your email address will not be published. Required fields are marked *