5

I just try to use Ajax on a website, to load products without refreshing the website. In console I get the following error:

POST https://mywebsite.com/wp-admin/admin-ajax.php 500    jquery.min.js?ver=3.5.1:2

I try to increase WP_MEMORY_LIMIT and WP_MAX_MEMORY_LIMIT but still I get the same error.

What is the reason for this error? and How I can fix it?

Sallar Rabiei
  • 630
  • 1
  • 12
  • 33
  • 1
    Where are you making this request (theme, plugin, elsewhere)? Do you have a hook setup to accept the request you are making? – mikerojas Mar 24 '21 at 15:45
  • Thanks @mikerojas, I use ajax in a plugin for filtering products. – Sallar Rabiei Mar 24 '21 at 15:50
  • 1
    To confirm do you have a `wp_ajax_{your action}` hook/function setup to capture your ajax requests? – mikerojas Mar 24 '21 at 15:54
  • No, I do not have `wp_ajax` is it crucial? I mean should I use `wp_ajax`? – Sallar Rabiei Mar 24 '21 at 15:55
  • 2
    Please provide in your question all related code… Note that *"The question should be updated to include desired behavior, a specific problem or error, **and the shortest code necessary to reproduce the problem**"*. – LoicTheAztec Mar 24 '21 at 16:02
  • Thanks @LoicTheAztec , in fact I do not use any code, I just use `Product Filters plugin` and there is an option to use ajax, and anytime I enable `use ajax` I face this error and plugin do not work. – Sallar Rabiei Mar 24 '21 at 16:10
  • @M.SallarRabiei So you should report the problem in the plugin support threads… This also can be due to some other code added by you. Also another plugin or your theme can be involved in this issue. You should enable Wordpress debug as explained in the [2nd part of this answer](https://stackoverflow.com/a/61754061/3730754) to have more details. – LoicTheAztec Mar 24 '21 at 16:16
  • @LoicTheAztec I found this problem related to the theme that I designed. I change the theme to default WordPress theme and ajax work. Is it related to `wp_enqueue_scripts`? or I should use a specific CDN in the header or footer? – Sallar Rabiei Mar 25 '21 at 00:02

3 Answers3

1

For me it happened when I installed and activated a plugin that wasn't tested/approved for my version of Elementor (or for your version of Wordpress in your case perhaps). Removing that will "fix" it.

user3035649
  • 472
  • 1
  • 4
  • 12
0

Internal server errors (error 500) are often caused by plugin or theme function conflicts, so if you have access to your admin panel, try deactivating all plugins. If you don't have access to your admin panel, try manually resetting your plugins (no Dashboard access required).

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 18 '22 at 06:48
-1

https://www.wpbeginner.com/wp-tutorials/how-to-fix-failed-to-load-resource-error-in-wordpress/

Its bizar! If the missing resource is an image in one of your blog posts or page, then try to look for it in the media library.

Replace missing image

If you can see it in the media library, then try to add it again by editing the post or page. If you cannot see the file in the media library, then try uploading it again.

In some cases, you may see broken images or empty boxes in the media library instead of images. In that case, you may need to fix the file permissions. For detailed instructions, see our tutorial on how to fix image upload issues in WordPress.