Using Ajax call in jQuery doesn’t work in widget

If your AJAX Url is conversion.php it will most likely point to yourdomain.com/conversion.php.
Is your file in that location?

Looks like not, and I guess you don’t have a 404.php, and in that case your request gets directed to your index.php, that’s why you get the contents of your homepage.

If your file is in your theme folder, you would have to change the URL to wp-content/themes/yourtheme/conversion.php

But the much easier and recommended way is to use WP built in AJAX functionality:
See this codex page for more informations:
http://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_(action)

EDIT: Most posts on this topic are for AJAX on the WordPress backend but it’s possible to use it on the frontend as well.

Leave a Comment