0

I am trying to get an ajax response on WordPress, currently, it's showing me a 404 error on the staging server but on dev it's working fine.

I know the problem is due to the use of "forward-slash(/)" in the URL on staging but on dev it's working with or without forward-slash just after admin-ajax.php. Please check the below URL so that you all can understand this in detail

Staging Environment:

URL NOT WORKING(with / ) on staging:

staging/wp-admin/admin-ajax.php/category/movies/?action=get_movies?action=get_my_post

URL WORKING WITHOUT ( / ) on staging:

staging/wp-admin/admin-ajax.php/category/movies/?action=get_my_post

Dev Environment:

URL WORKING(with / ) on staging:

staging/wp-admin/admin-ajax.php/category/movies//?action=get_my_post

URL WORKING WITHOUT ( / ) on staging:

staging/wp-admin/admin-ajax.php/category/movies/?action=get_my_post

as you can see if I remove forward-slash after admin-ajax.php it's working fine on staging but with a forward-slash , it's not working, where is dev environment it's working with our without forward-slash

Ajax code:

function get_movies()
{
   require_once themespro_classifier_addon_template_exsits('movies/templates/grid');
    get_search_tems( $category_for_push ,$paged);
  
    wp_die();  
    
}
13
  • 1
    .php files generally wouldn't have a trailing forward slash /. Have you checked your HTACCESS file rules in the WordPress root folder?
    – Howdy_McGee
    Jun 16, 2021 at 16:31
  • @Howdy_McGee yes I have checked we are using the same .htaccess on both servers Jun 16, 2021 at 16:37
  • How are you making the request? Are you using a relative URL? Jun 16, 2021 at 16:40
  • @JacobPeattie yes i am using relative url Jun 16, 2021 at 16:42
  • 1
    You should try an absolute URL. Jun 16, 2021 at 16:43

0

Your Answer

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

Browse other questions tagged or ask your own question.