WordPress: My Ajax call always returns 0 in Internet Explorer – what’s going on?

This post is for everyone who have exhausted all Ajax options on stackoverflow and still return a response body of 0.

Go to your functions.php and check your add_action which should look similar to the below:

add_action('wp_ajax_myfunction', 'myfunction');

This is perfectly fine and works … if you’re logged in to WordPress already.

You need to add a second add_action line

add_action('wp_ajax_nopriv_myfunction', 'myfunction');

This will now work for users who were not logged in to WordPress.

If that fixed your ajax issue

You simply forgot to add an action for users without privileges. For any form that was being submitted that’s going to hurt as that data probably wasn’t captured.

Side note:

The above has absolutely nothing to do with Internet Explorer apart from the fact that you most likely aren’t logged in to the CMS on IE.

More refs: