Why is my Ajax call not working in WordPress?

Why is my Ajax call not working in WordPress?

Cleared cache, deactivated caching plugin for the time-being. The second, less obvious issue was that, for NOT logged-in users, the response from the AJAX call was returning the entire HTML document in the response area. It turns out I had a “redirection” function in my functions.php file that was causing this.

What to do if Ajax function is not working?

For anyone else who happens to have the same problem, here is a possible solution that worked for me. Simply reformat the code to be the following:

Do you have an error handler in Ajax?

You can choose to handle the error however you wish but it is best practice to have the error handler in case of an exception. Also, the formatting of the success and error functions within the ajax function are different. This is the only format for success/error that would work for me.

Why is the submit function not working in jQuery?

When I click on the submit button , my ajax request is not working , it looks as if the control is being passed to the JQuery submit function , but the ajax request is not executing/working properly,what is wrong ? put the event handler function inside $ (document).ready (function () {…}). it shall work now

What causes admin Ajax to be blocked in PHP?

Caching plugins. Occasionally caching plugins can cause problems with admin-ajax.php by either breaking the javascript that creates the ajax requests or by simply making admin-ajax.php inaccessible

What should I do if Ajax is not working?

If your ajax is not working, check to see what rules your .htaccess file contain. If there are any rules beyond those shown below, remove them and see if ajax begins working again. Your htaccess file will usually contain rules that look like this (these are perfectly safe and normal):

Why is Ajax not working on Apache server?

If ajax begins working after disabling the firewall, you have found the culprit. If ajax is still inaccessible after disabling the firewall, you can usually safely re-enable it. The .htaccess file used on apache servers can sometimes include special rules that are designed to protect your site from attacks.