Admin ajax php 500 internal server error

Hello, Since the new version 2.4, I'm having problems in one computer (which is very strange), that does not load the media Library and Variations (modules with ajax). I've updated every pl...

Hello,
Since the new version 2.4, I’m having problems in one computer (which is very strange), that does not load the media Library and Variations (modules with ajax). I’ve updated every plugin and WordPress 4.3 but it does not solve it. It has to be related with Woocommerce, because when I deactivate it, it does not have any problem.

This is the error message in Console:
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,plupload&ver=4.3:5 POST https://equitienda.es/wp-admin/admin-ajax.php
500 (Internal Server Error)send @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,plupload&ver=4.3:5m.extend.ajax @ load-scripts.php?c=0&load[]=jquery-core,jquery-migrate,utils,plupload&ver=4.3:5j @ load-scripts.php?c=0&load[]=hoverIntent,common,admin-bar,underscore,shortcode,backbone,wp-util,wp-b…:376(anonymous function) @ load-scripts.php?c=0&load[]=hoverIntent,common,admin-bar,underscore,shortcode,backbone,wp-util,wp-b…:376

Regards.

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 Rabiei's user avatar

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

user3035649's user avatar

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

Al-Mutasem Abbad's user avatar

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

Plustag Eduardo's user avatar

1

I’m getting 500 errors with AJAX on the admin side. However, these errors aren’t being logged in the Apache logs so they’re rather hard to debug.

Is there some way I can find out what they are?

Thanks

asked Mar 2, 2012 at 13:16

djb's user avatar

1

Sometimes I have a 500 error ( from NGinx ) just because I have a «character» getting outputted before the first header gets written ( or in-between ).

Activate WP_DEBUG = true and see what happens. 99% of the case I could spot the error from there. ( and it was nearly all the time the above error ).

Post back if that doesn’t solve your debug difficulty problem. We’ll have a look at your apache config by then.

answered Mar 2, 2012 at 14:24

nembleton's user avatar

nembletonnembleton

3492 silver badges3 bronze badges

1

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

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:

IIS trace error

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:

IIS trace error

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.

  • Bookly works fine when I’m logged into wordpress. But when customers view it they get the endless loading spinner.

    This error is in devtools:
    Failed to load resource: the server responded with a status of 500 ()
    wp-admin/admin-ajax.php?action=bookly_render_time&csrf_token=8ba999b011&form_id=5f9b8b295addc&new_chain=true

    Here’s the debug log:

    [30-Oct-2020 03:33:43 UTC] PHP Notice:  Trying to access array offset on value of type null in /nas/content/live/thedirt4wd/wp-content/plugins/bookly-responsive-appointment-booking-tool/frontend/modules/booking/Ajax.php on line 1167
    [30-Oct-2020 03:33:43 UTC] PHP Notice:  Trying to access array offset on value of type null in /nas/content/live/thedirt4wd/wp-content/plugins/bookly-responsive-appointment-booking-tool/frontend/modules/booking/Ajax.php on line 1168
    [30-Oct-2020 03:33:43 UTC] PHP Notice:  Trying to access array offset on value of type null in /nas/content/live/thedirt4wd/wp-content/plugins/bookly-responsive-appointment-booking-tool/frontend/modules/booking/Ajax.php on line 1169
    [30-Oct-2020 03:33:43 UTC] PHP Notice:  Trying to access array offset on value of type null in /nas/content/live/thedirt4wd/wp-content/plugins/bookly-responsive-appointment-booking-tool/frontend/modules/booking/Ajax.php on line 1195
    [30-Oct-2020 03:33:43 UTC] PHP Fatal error:  Uncaught Error: Call to a member function withSubServices() on bool in /nas/content/live/thedirt4wd/wp-content/plugins/bookly-responsive-appointment-booking-tool/lib/slots/Finder.php:411
    Stack trace:
    #0 /nas/content/live/thedirt4wd/wp-content/plugins/bookly-responsive-appointment-booking-tool/lib/slots/Finder.php(106): BooklyLibSlotsFinder->_prepareStaffData()
    #1 /nas/content/live/thedirt4wd/wp-content/plugins/bookly-responsive-appointment-booking-tool/frontend/modules/booking/Ajax.php(208): BooklyLibSlotsFinder->prepare()
    #2 [internal function]: BooklyFrontendModulesBookingAjax::renderTime()
    #3 /nas/content/live/thedirt4wd/wp-content/plugins/bookly-responsive-appointment-booking-tool/lib/base/Ajax.php(52): call_user_func(Array)
    #4 /nas/content/live/thedirt4wd/wp-content/plugins/bookly-responsive-appointment-booking-tool/lib/base/Ajax.php(31): BooklyLibBaseAjax::forward('renderTime', true, true)
    #5 /nas/content/live/thedirt4wd/wp-includes/class-wp-hook.php(287): BooklyLibBaseAjax::BooklyLibB in /nas/content/live/thedirt4wd/wp-content/plugins/bookly-responsive-appointment-booking-tool/lib/slots/Finder.php on line 411
    

    The page I need help with: [log in to see the link]

  • Hi there!
    I have the weirdest problem ever!
    Using enfold theme on my wordpress site. Getting error:
    Domain.com/wp-admin/admin-ajax.php 500 (Internal Server Error) – domain.com/wp-admin/load-scripts.php?c=0&load%5Bchunk_0%5D=jquery-core,utils,moxiejs,plupload&ver=5.5.1

    This happen when I click on any ALB element on a page like slideshow, title etc.. the popup modal is gettion opened, the loading wheel sping for 3 seconds and than getting white blank.

    Now thats the interesting part – this is only happen if I have more than 1740 *published pages* – as soon I move a few pages to the trash, and the total number of pages below 1740 – everything works perfectly!
    Tried to increase php limit to 1g, change php version 7.1-7.4, debugging – nothing, deactivate & removed all plugins, optimize, clean & repair db, increase max_allowed_packet & innodb_buffer_pool_size, everything.
    running latest wordpress version with the latest enfold release.
    My only assumption is that somehow the admin-ajax.php close/abort the connection because of large query from database? Or timeout?

    Anyone face something like that before? i searched the entire forum for the ajax 500 problem saw just a few that exactly related, tried every solution someone offer with no luck, i come to you as my last resort.
    Thank you very much guys!

    • This topic was modified 2 years, 4 months ago by ottwebtech.

    Понравилась статья? Поделить с друзьями: