I'm getting this 500 error in the browser:

HTTP500: SERVER ERROR - The server encountered an unexpected condition that prevented it from fulfilling the request. (XHR)POST - https://www.example.com/wordpress/wp-admin/admin-ajax.php

Below is my code. This gets executed when I press the submit button. When the submit is clicked, this alert: alert('!!!Submission Error!!!'); pops up followed by the above error on the console. I couldn't figure out what's happening. I have the same copy of the site in my staging environment, where it doesn't show any error.

        url: jquery_main_data.ajaxurl,
        data : {
            action : jquery_main_data.action_form,
            fields : fields,
            nonce: jquery_main_data.nonce_form
        type : 'post',
        dataType: "json",
        beforeSend: function() {
        success: function(response) {

            if(response.is_valid == true) {
                    window.location.href = '/thank-you/';
            } else {
        always: function() {
        error: function(errorThrown){
            alert('!!!Submission Error!!!');

  • JavaScript can’t cause a 500 error on its own. The problem will be in the PHP code you’re using on the back end. What’s that code? – Jacob Peattie Nov 9 '18 at 16:27
  • Does example.com/wordpress/wp-admin/admin-ajax.php exist? – mediaguru Nov 9 '18 at 20:42
  • @mediaguru Yes that link does exist. This issue got resolved by itself but I'm keen to learn how. When I tested the site after 5 hours, the site had already started working and receiving form submissions. The web host said they didn't fix anything on their end. I noticed the issue after I updated WP and some plugins. But how did it fix by itself? – user1448031 Nov 12 '18 at 6:50
  • Maybe there was a cache issue which cleared when the cache cleared. – mediaguru Nov 12 '18 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.