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?
asked Mar 24, 2021 at 15:41
Sallar RabieiSallar Rabiei
5351 gold badge11 silver badges31 bronze badges
8
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.
answered Jun 27, 2022 at 15:34
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).
answered Jul 14, 2022 at 16:45
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.
answered Mar 27, 2021 at 18:57
1
I have a single WordPress 4.9.16 website that is throwing Error 500s when taking many actions in the admin interface. When I try to do things like add a new category, nothing happens in the front end and my web inspector shows the error.
I have tried:
- Renaming my .htaccess file and letting WP rebuild a new one
- Increasing WordPress memory limit
- Increasing PHP memory limit
- Disabling all plugins
- Re-uploading core files in wp-admin and wp-includes
And after taking each of those steps, I still experience an admin-ajax error 500 when trying to add a category.
My next steps are to either
- Change my theme
- Update to 5.6 current release.
I have a few questions, but basically it all comes down to how to fix my admin-ajax 500 error.
- If I change my theme to something out of the box (one of the Twenty ______ themes), and then change my theme back to my current theme (a child of Spacious Free), am I likely to experience big problems? Or will most/all of the configurations remain?
- Is it likely that I will be able to update to 5.6 if I’m receiving this error? It feels like this is a logical step in diagnosing the issue. I’ve been holding off because I haven’t had a chance to test the site in 5.x, though.
- What else should I be looking for?
Thanks.
-Ben
asked Feb 2, 2021 at 18:51
1
Isn’t it the case that once you write up what you’ve tried, you find that one last thing to try that works?
I just discovered that my admin-ajax file had 000 permissions. I reset to 644 and everything started working properly again.
answered Feb 2, 2021 at 19:02
1
Question
Having a problem with WordPress Ajax calls. In the development environment and in the admin mode on the production server, the ajax works perfectly. When the JQuery post call is made by the same code and with the same, well formatted, request data on the front-end, it fails. Debugged the client side and got the same server response with both the Safari Web Inspector and the Chrome Developer tools. The error message is Internal Server Error (500). What’s going on with IIS 10.0 ? How to set up IIS to accept front-end Ajax calls? Should I install Ajax.Net ?
Solution
AJAX (Asynchronous JavaScript And XML) is a client-side technology. On the server side the IIS can’t distinguish between normal web page and AJAX POST, GET requests. There is no need to ‘setup’ your IIS or Apache for AJAX. jQuery is nothing else than an easy-to-use wrapper for the native JavaScript. ASP.NET AJAX is a set of technologies to add AJAX support to ASP.NET. It integrates client script libraries with the ASP.NET. It has nothing to do with your PHP WordPress side.
500 internal server error is an irritating all-you-cannot-eat message. To trace the error, first look at the logs of IIS to discover something more about the infamous error, and second, find and look at the WordPress plugins and themes, ie. the PHP code. The typical cause is conflicts between plugins and/or themes, including child theme with your code. It’s true for other technologies as well, always look at the web site installation, identify possible conficts, and check out your server side code.
IIS detailed error log
1. On Windows Server 2008/2012 you can use Advanced Logging option of IIS 7.5 or 8. You may need to download and install it from Microsoft. Check out the latest version if it’s already available for IIS 10.
2. Go to the server. Just to be sure, look at the folders of PHP and website if permissions are set properly. Open IIS Manager, select server and website. Enable Trace Logging for Failed Requests regardless of the use of the Advanced Logging option. In the Actions pane at the Configure group, click Failed Request Tracing and set the directory you will use:
3. Open your web browser and load the website. When needed, activate whatever you need to run the AJAX call, for example click on a button if that initiate the call. Recheck AJAX ‘data’ request if it’s really formatted well.
4. Go back to the server, find the log directory where you will be greated by a couple of large xml files. Open the latest one the IIS generated when serving your site’s request. If you run into an access error, copy the file into a folder where you have open/read permissions. Well, you’ll spend some time to locate the line you really wanted to see. Like this:
Now we know that in this case the 500 error is triggered by ‘Reached the end of the file’. That rarely means the PHP had problems reading a physical file though.
WP plugin conflicts at handling AJAX calls
1. Must do checklist
– Step A: disable all other plugins or themes.
– Step B: reload the web site on the client side. Check out if the 500 error pops up. If not, activate the next plugin.
– Step C: go back to Step B and repeat it until the suspect has been caught. If you are lucky.
If not, your code is likely in conflict with WordPress (PHP installation) or parent theme.
2. PHP, WordPress and your code
Probably you are unlucky and found nothing so far. Switch on WP debug mode (wp-config.php) and see if it helps locate suspects:
Likely found something relevant here.
3. admin-ajax.php
You may want to diagnose and look at admin-ajax.php to see how server responses (How ? Use Chrome Developer tools for example). Initially admin-ajax.php was used for autosave, post locking and log-in expiration warnings. You will notice third party plugins polling this file frequently, thinking it’s a horse race, that may cause problems without any code error, but doing nothing good at all. Each POST request had a corresponding PHP script execution on the server using expensive CPU time.
4. Your code
We all have bad days and write bad codes, and sometimes need another two eyes to catch the obvious. Invite someone to look at your code and offer a free cup of tea.
How to fix ajax POST /wp-admin/admin-ajax.php 500 (Internal Server Error)? I’m receiving this error in console when I’m about to call my ajax code backend. It appears to me that I am missing global variable in enable the code to work. See the wrong and correct coding below. It might be not the same issue on you but you can found a clue how to fix 500 (Internal Server Error) error.
Wrong code, missing “global $wpdb;” global variable and this is causing 500 (Internal Server Error) error
// JS CODE jQuery( document ).ready( function( $ ){ $( '#gallery #select-friend' ).keyup( function(){ $.ajax({ url : ajaxurl, type : 'post', data : { action : 'ys_creadit_to', keyword : $( '#gallery #select-friend' ).val() }, success : function(data){ console.log(data); } }); }); }); // PHP CODE add_action( 'wp_ajax_ys_creadit_to', 'ajax_creadit_to' ); add_action( 'wp_ajax_nopriv_ys_creadit_to', 'ajax_creadit_to' ); function ajax_creadit_to(){ $keyword = isset( $_POST['keyword'] ) ? explode( ' ', $_POST['keyword'] ) : array(); $s = ""; if( $keyword ) : foreach( $keyword as $id => $word ) : if( $id != 0 && ( ( count( $keyword ) - 1 ) < $id ) ) : $s .= " OR "; endif; $s .= "(display_name LIKE '%$word%')"; endforeach; endif; $results = $wpdb->get_results( "SELECT ID, display_name FROM wp_users WHERE display_name LIKE '%$s%' LIMIT 0, 50" ); print_r( $results ); die(); }
Correct and working code
// JS CODE jQuery( document ).ready( function( $ ){ $( '#gallery #select-friend' ).keyup( function(){ $.ajax({ url : ajaxurl, type : 'post', data : { action : 'ys_creadit_to', keyword : $( '#gallery #select-friend' ).val() }, success : function(data){ console.log(data); } }); }); }); // PHP CODE add_action( 'wp_ajax_ys_creadit_to', 'ajax_creadit_to' ); add_action( 'wp_ajax_nopriv_ys_creadit_to', 'ajax_creadit_to' ); function ajax_creadit_to(){ global $wpdb; $keyword = isset( $_POST['keyword'] ) ? explode( ' ', $_POST['keyword'] ) : array(); $s = ""; if( $keyword ) : foreach( $keyword as $id => $word ) : if( $id != 0 && ( ( count( $keyword ) - 1 ) < $id ) ) : $s .= " OR "; endif; $s .= "(display_name LIKE '%$word%')"; endforeach; endif; $results = $wpdb->get_results( "SELECT ID, display_name FROM wp_users WHERE display_name LIKE '%$s%' LIMIT 0, 50" ); print_r( $results ); die(); }
Gravity Forms Image Upload Field for User Registration
Image Upload Field for User Registration is a Gravity Forms add-on that is specialize for front-end user registration form. It has the ability to upload a user avatar or profile picture during the user registration process. This field has advance settings that can help you adjust the preferred design on the front-end form such as image dimension (width and height), text button, etc. and other settings to enhance front-end layout.
Image Upload Field for User Registration requires Gravity Forms and Gravity Forms User Registration Add-On before install.
Add to cart VIEW PRODUCT
Gravity Forms Media Upload Field
Media Upload Field is a Gravity Forms add-on that allow users to upload an image with advance front-end setup, and easy to use image cropping. This field provide advance settings to manage the image dimension (width and height) and other settings that can be found in the front-end layout.
Add to cart VIEW PRODUCT
Viewing 12 replies — 1 through 12 (of 12 total)
The best thing to do is put WordPress in debug mode and examine the debug.log, which should have a FATAL error at the time you try the request ( ignore notices and warnings )
Then post the exact error message at the time causing the 500 error.
Debugging in WordPress
Thread Starter
Anonymous User 18608805
(@anonymized-18608805)
Alan-thanks for your quick response. Follow is what is written to the debug log. Note that I also get this error on Chrome’s console:
/wp-admin/admin-ajax.php:1 Failed to load resource: the server responded with a status of 500 ()
[09-Mar-2021 15:08:26 UTC] PHP Notice: Undefined index: captcha in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1292
[09-Mar-2021 15:08:26 UTC] PHP Notice: Undefined index: captcha in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1296
[09-Mar-2021 15:08:26 UTC] PHP Notice: Undefined index: maths in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1296
[09-Mar-2021 15:08:26 UTC] PHP Notice: Undefined index: useemail in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1427
[09-Mar-2021 15:08:26 UTC] PHP Notice: Undefined index: email in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1429
[09-Mar-2021 15:08:26 UTC] PHP Notice: Undefined index: yourmessage in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1436
[09-Mar-2021 15:08:26 UTC] PHP Notice: Undefined index: use_message in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1437
[09-Mar-2021 15:08:26 UTC] PHP Notice: Undefined index: srt in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1357
[09-Mar-2021 15:08:26 UTC] PHP Notice: Undefined index: recurring in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1363
[09-Mar-2021 15:08:26 UTC] PHP Notice: Undefined index: captcha in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1292
[09-Mar-2021 15:08:26 UTC] PHP Notice: Undefined index: captcha in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1296
[09-Mar-2021 15:08:26 UTC] PHP Notice: Undefined index: maths in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1296
[09-Mar-2021 15:08:26 UTC] PHP Notice: Undefined index: useemail in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1427
[09-Mar-2021 15:08:26 UTC] PHP Notice: Undefined index: email in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1429
[09-Mar-2021 15:08:26 UTC] PHP Notice: Undefined index: yourmessage in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1436
[09-Mar-2021 15:08:26 UTC] PHP Notice: Undefined index: use_message in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1437
[09-Mar-2021 15:08:39 UTC] PHP Notice: Undefined variable: currency in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1888
[09-Mar-2021 15:08:39 UTC] PHP Notice: Undefined index: custom in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1983
[09-Mar-2021 15:08:39 UTC] PHP Notice: Undefined index: stock in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 2030
[09-Mar-2021 15:08:39 UTC] PHP Notice: Undefined index: custom in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 1983
[09-Mar-2021 15:08:39 UTC] PHP Notice: Undefined index: stock in /home/hobbsc6/public_html/wp-content/plugins/quick-paypal-payments/legacy/quick-paypal-payments.php on line 2030
No FATAL errors? Can you double check – ignore NOTICeS and WARNINGS we are looking for FATAL ERRORS
Just to be totally clear – the ajax call is encountering a fatal error and so returning a 500 to the console.
There are a few reasons for this
1. it could be code – so the error log is critical in investigating, notices and warnings do not cause errors – fatal errors look very different with a stack trace
2. something is wrong with your server permissions ( this can happen for instance if you add htaccess rules to wp-admin without allowing ajax execution )
Thread Starter
Anonymous User 18608805
(@anonymized-18608805)
Hi Alan,
There are no fatal errors in the log – only a stream of those PHP errors. I also checked the htaccess and nothing there would be blocking. My client has been using the plugin for months and this seemed to start happening only recently. Anything we can try to get this working for them? It’s odd that all of a sudden it has stopped working. They are running the most recent version of the plugin.
I would expect a fatal error in the logs if the plugin is failing.
You could try an earlier version you get that form here
https://wordpress.org/plugins/quick-paypal-payments/advanced/
I would suggest 5.7.8
That way you will know definitely if it is related to the version if the earler version works.
You can also go to tools>healthcheck and download the configuration so I can see what versions etc.
And you could screen shot all the settings pages so I can see if I can replicate in test.
Thread Starter
Anonymous User 18608805
(@anonymized-18608805)
Seems to be the newer plugin. Downgraded the plugin as you recommended and it works fine.
OK I will need help in debugging some how though. Can you send through your screen shots of settings
you can use the email support at fullworks.net
I’m especially interested if you are using ‘personal detail’ fields – as that part changed in the last two releases.
Also is it possible you try 5.7.9 as that narrows it down further.
-
This reply was modified 1 year, 11 months ago by
Alan Fuller.
Can you advise you PHP version, as it has been reported that the latest version doesnt work with old PHP versions.
Thread Starter
Anonymous User 18608805
(@anonymized-18608805)
Running version 7.4.
Did this resolve itself?
-
This reply was modified 1 year, 7 months ago by
Alan Fuller.
Thread Starter
Anonymous User 18608805
(@anonymized-18608805)
Sadly no, but we went with another option with PayPal. However, thank you so much for all the help you provided… you went above and beyond to assist. I think it was just something going on with our particular setup or host that was causing these problems. You can close out this ticket. Thanks again for your help!
Viewing 12 replies — 1 through 12 (of 12 total)