Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

148
Views
Ajax 500 error cause investigation method

I want to get the url sent by Ajax in fuctions.php on the site made by Wordpress.   With the current code, the following error is displayed on the console.
I checked it from the network with the verification tool, but the preview is a white background and no response is displayed.
I would like to find out the cause of the error, what should I do?

Error

XMLHttpRequest : 500
textStatus     : error
errorThrown    : undefined

Code
main.js

(function($) {
    var url_category = location.href;
    var ajaxUrl = window.location.protocol + '//' + window.location.host + '/wp-content/themes/example/functions.php';
    $.ajax({
        url: ajaxUrl,
        type: "GET",
        data: { url_category: url_category },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            console.log("Failed!");
            console.log("XMLHttpRequest : " + XMLHttpRequest.status);
            console.log("textStatus     : " + textStatus);
            console.log("errorThrown    : " + errorThrown.message);
        },
        success: function (response) {
            console.log("Success!");
            console.log(url_category);
        }
    });
})(jQuery);

functions.php

add_action('wp_ajax_get_case', 'dk_get_case');
add_action('wp_ajax_nopriv_get_case', 'dk_get_case');
function dk_get_case() {
    $headers['Access-Control-Allow-Origin'] = '*';
    $return = ['status' => false, 'data' => [], 'message' => ''];

    $url = $_POST['url_category'];
}
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!